//ads:
?>
php curl_exec() Connection refused when retrieving a remote image
PHP Snippet 1:
curl http://img107.xooimage.com/files/5/0/b/ss-2014-06-15-at-12.58.47--46324f5.png > image.png
PHP Snippet 2:
$ch = curl_init('http://img107.xooimage.com/files/5/0/b/ss-2014-06-15-at-12.58.47--46324f5.png');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR,true);
$image = curl_exec($ch);
if (curl_errno($ch)) {
print_r(curl_error($ch));
die;
}
curl_close($ch);
return $image;
PHP Snippet 3:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'http://img107.xooimage.com/files/5/0/b/ss-2014-06-15-at-12.58.47--46324f5.png');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$image = curl_exec($ch);
var_dump($image); // Binary content
$save = fopen('image.png', 'w');
fwrite($save, $image);
fclose($save);
curl_close($ch);