Reputation: 2032
this is my curl function:
function curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'picturecookies.txt');
curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/");
curl_setopt($ch, CURLOPT_URL, $url);
$return = curl_exec($ch);
return $return;
}
an example image im trying to get:
http://static.fjcdn.com/large/pictures/39/29/3929d8_2637027.jpg
when i try getting the image with curl, i only get a file with random filesizes each time. heres a list of bytes returned 6 times in a row;
12 654
12 627
12 632
12 632
12 583
12 627
the example image is 655kB
what am i doing wrong here?
EDIT:
I found why :> The images are hotlink protected. It was simply solved by changing the referer to the url the image was presented on.
Upvotes: 0
Views: 351
Reputation: 336
You are probably getting redirecteed to the funnyjunk index page without noticing ;-)
Upvotes: 1