我使用PHP Facebook API(连同laravel)
我可以设法从页面获取Feed,并使用
发布所有帖子 $request = Facebook::get('/COMPANYPAGE?fields=feed.limit(25)');
$response = $request->getGraphPage()->getField('feed');
返回以下对象
但我似乎无法获得该帖子的具体信息!喜欢 包含的图像..我需要执行另一个电话吗?
我尝试了以下操作,但它给了我相同的结果
$request = Facebook::get('/elbeko?fields=feed.limit(25)');
$response = $request->getGraphPage()->getField('feed');
foreach($response as $item) {
$post = Facebook::get($item['id'])->getGraphObject();
}
答案 0 :(得分:14)
从v2.4开始,您必须指定要从Grpah API返回的每个字段。你应该可以使用
/elbeko/feed?fields=id,message,link,attachments{media}&limit=25
返回类似
的内容{
"data": [
{
"id": "1472127519670095_1645415342341311",
"message": "Benieuwd naar ons nieuw project in de regio Gent? Binnenkort meer info via www.elbeko.be!",
"link": "https://www.facebook.com/elbeko/photos/a.1589552831260896.1073741835.1472127519670095/1645415342341311/?type=3",
"attachments": {
"data": [
{
"media": {
"image": {
"height": 405,
"src": "https://scontent.xx.fbcdn.net/hphotos-xpl1/v/t1.0-9/s720x720/11954813_1645415342341311_5204470874884096944_n.jpg?oh=0a7e10b12d3feb90b2de79fa60a7f8f8&oe=56C30337",
"width": 720
}
}
}
]
}
}
],
"paging": {
"previous": "https://graph.facebook.com/v2.5/1472127519670095/feed?fields=id,message,link,attachments%7Bmedia%7D&limit=2&format=json&since=1441790055&access_token=&__paging_token=&__previous=1",
"next": "https://graph.facebook.com/v2.5/1472127519670095/feed?fields=id,message,link,attachments%7Bmedia%7D&limit=2&format=json&access_token=&until=1441124382&__paging_token="
},
}
见
过去,Graph API调用的响应返回了一组默认字段。为了减少有效载荷大小并改善移动网络上的延迟,我们减少了大多数Graph API调用返回的默认字段数。在v2.4中,您需要以声明方式列出呼叫的响应字段。