试图卷曲得到图像,但我得到奇怪的结果

时间:2011-09-21 21:59:36

标签: php curl

这是我的卷曲功能:

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;
}

我试图获得的示例图片:

http://static.fjcdn.com/large/pictures/39/29/3929d8_2637027.jpg

当我尝试使用curl获取图像时,我每次只获得一个带有随机文件大小的文件。 继承了连续6次返回的字节列表;

12 654
12 627
12 632
12 632
12 583
12 627

示例图像为655kB

我在这里做错了什么?

编辑:

我找到了原因:> 图像受热链接保护。 它只是通过将引用者更改为呈现图像的URL来解决。

1 个答案:

答案 0 :(得分:1)

您可能会在没有注意到的情况下重定向到funnyjunk索引页面; - )

相关问题