Facebookから画像のURLを取得しました:
https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-prn1/s720x720/156510_443901075651849_1975839315_n.jpg
これをローカルに保存する必要があります。使用file_get_contents
するとエラーが発生しましfailed to open stream
た。ブラウザで画像を開くと、正常に表示されます。私はそれを行う方法を理解しています。
実際、次の方法でcurlを使用しましたが、まったく応答がありませんでした
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$response = curl_exec($ch);
curl_close($ch);
$filename = 'ex'.$src['photo_id'].'.jpg';
$imgRes = imagecreatefromstring($response);
imagejpeg($imgRes, $filename, 70);
header("Content-Type: image/jpg");
imagejpeg($imgRes, NULL, 70);