グラフapiで画像を表示し、cUrlを使用してディスクに保存しようとしましたが、mimeを確認しようとするとこのエラーが発生しますcURLでユーザーの表示画像を取得して保存することができません
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
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
を使用して、この更新されたコードのための
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);
:私は保存された画像の種類
この操作でサーバー側の設定が必要な場合は、phpfog
以上の共有クラウドストレージを使用しているため、これを行うことができない場合があります。
こんにちは。
ありがとうございます。
画像にアクセスするための許可がアプリケーションに与えられていますか? – Reinard
はいiveすべての必要な権限。 – Maven
@Sir -/id/picture経由の画像は公開されています - Maven - tempディレクトリの画像を見てください - あなたが期待していることを確認してください - またfile_get_contentsを試してください(URLで動作します) – scibuff