从facebook下载个人资料图片不再工作

时间:2016-11-16 10:39:50

标签: php facebook graph

这在几天或几周之前就开始了:

$image = file_get_contents('https://scontent.xx.fbcdn.net/v/t1.0-1/p720x720/13001320_100996553638879_478536659476895885_n.jpg?oh=ec91a8418298a51403eaa306f62f9ab3&oe=58C0E384');
file_put_contents('bla.jpg', $image);

但现在不再了。我以这种方式检索URL:

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);
$array['data']['url']; // image url

0 个答案:

没有答案