如何通过Facebook提供的图片网址保存Facebook个人资料图片?

I have used following code to save the facebook profile pic by url provided by facebbok

$data = file_get_contents('https://graph.facebook.com/[App-Scoped-ID]/picture?width=378&height=378&access_token=[Access-Token]');
$file = fopen('fblogo/fbphoto.jpg', 'w+');
fputs($file, $data);
fclose($file);

The image saved on desired place but it saved by 0 byte means corrupt, please let know how to save the image properly

I use this:

$image = json_decode(file_get_contents("https://graph.facebook.com/$data[id]/picture?width=800&height=600&redirect=false"),true);
$image = file_get_contents($image['data']['url']);
file_put_contents("desired_filename.jpg",$image);

This looks like my answer from this thread: Save facebook profile image using cURL

Try adding redirect=false to the API call to get the real location of the picture. And if that does not work, try with CURL:

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/' . $app_scoped_id . '/picture?width=378&height=378&redirect=false&access_token=xxx');
$data = curl_exec($ch);
$data = json_decode($data);

This will get the real URL, and you can use another call to get the image:

curl_setopt($ch, CURLOPT_URL, $data->data->url);
$data = curl_exec($ch);
curl_close($ch);

And if that does not work either, make sure your provider supports CURL requests :)