我試圖通過圖形api檢索用戶顯示圖片,並使用cUrl將其保存到磁盤中,但無法成功並在嘗試檢查MIME時出現此錯誤無法通過cURL檢索並保存用戶的顯示圖片
Notice: exif_imagetype(): Read error! in
//$userPpicture = $user_profile[picture];
//Create image instances
$url = "http://graph.facebook.com/{$userId}/picture?type=large";
$dpImage = 'temp/' . $userId . '_dpImage_' . rand().'.jpg';
echo $dpImage;
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$returned_content = get_data($url);
file_put_contents($dpImage, $returned_content);
echo "Type: " . exif_imagetype($dpImage);
使用curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
我收到此錯誤此更新的代碼:
Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /var/fog/apps/app12345/myapp.phpfogapp.com/start.php on line 178
如果此操作需要任何服務器端配置的話,我可能不會爲我使用一個共享的雲存儲在phpfog
能夠做到這一點。
請幫助我。
三江源。
你確定權限給予了應用程序訪問的圖片? – Reinard 2012-03-26 14:48:01
是所有必需的權限。 – Maven 2012-03-26 14:49:26
@Sir - 通過/ id /圖片的照片公開可用 - Maven - 查看臨時目錄中的圖像 - 檢查你是否得到你所期望的 - 還可以嘗試file_get_contents(它適用於URL) – scibuff 2012-03-26 14:50:30