使用此网址时:
https://graph.facebook.com/fb_user_id/picture?height=600&redirect=false
你会看到json:
{
"data": {
"height": 720,
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p720x720/13001320_100996553638879_478536659476895885_n.jpg?oh=ec91a8418298a51403eaa306f62f9ab3&oe=58C0E384",
"width": 720
}
}
在某些日子之前,我可以下载图片:
$array = file_get_contents('https://graph.facebook.com/' . $fbid . '/picture?height=600&redirect=false');
$array = json_decode($array,true);
$image = file_get_contents($array['data']['url']);
file_put_contents($bildname, $image);
但现在我无法做到这一点:(
echo '<pre>';
var_dump($array);
echo '</pre>';
显示:bool(false)
有什么想法吗?
答案 0 :(得分:0)
适用于curl:
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);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$returned_content = get_data('https://graph.facebook.com/' . $fbid . '/picture?height=600&redirect=false');
$array = json_decode($returned_content,true);