added php example

This commit is contained in:
Christian Haschek 2015-09-28 15:23:50 +02:00
parent c19829233a
commit b216bf11c8

View File

@ -28,10 +28,27 @@ https://your-url-and.path/api.php?[OPTIONS]&url=[WEBSITE_URL]
The requested page will render as image (not provide a link). So you can use the path to your api.php file like so:
```
```html
<img src="https://your-url-and.path/api.php?url=http://xkcd.com" title="screenshot of xkcd.com" />
```
### Example php script to proxy an image to the local server
```php
<?php
$targeturl = 'http://www.xkcd.com';
$url = 'https://http2pic.haschek.at/api.php?url='.rawurlencode($targeturl);
$ch = curl_init($url);
$fp = fopen('xkcd.jpg', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
```
---
This is a [HASCHEK SOLUTIONS](https://haschek.solutions) project