When trying to retrieve a webcam image remotely with PHP cURL, I get a "connection refused" error. If I try to retrieve the image using the URL in a browser on my local machine, I am prompted for credentials, and then it gives me the image. Why is this happening? There shouldn't be any difference in who's asking for the image, either myself locally or the script on another server, correct?
My code:
<?php
$token = "user:password";
$url = "http://000.000.000.000:000/cgi-bin/image.jpg";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_USERPWD, $token);
/*curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);*/
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if( curl_exec($ch) === false ){
echo curl_error($ch);
}else{
$data = curl_exec($ch);
}
curl_close($ch);
echo "<pre>";
print_r($data);
echo "</pre>";
?>