我用:http://graph.facebook.com/{user_id or page_id}?fields=cover
浏览器返回:
{
"cover": {
"id": "XXX",
"source": "https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-ash4/311205_989690200741_1231438675_n.jpg",
"offset_y": 66
},
"id": "XXXXXX"
}
如何获取字段和source
变量?offset_y
PHP
我的功能:
function cover_img($fb_user_name) {
$cover_data = 'https://graph.facebook.com/'.$fb_user_name.'?fields=cover';
$JSONString = file_get_contents($cover_data);
$parsedJSON = json_decode($JSONString);
echo $source = $parsedJSON->cover->source;
echo $offset_y = $parsedJSON->cover->offset_y;
}