我需要获取通过PHP发布到页面的图片,目前它只提取消息但不提取图片。我是v5的新手所以问题是,如何从帖子中获取图片? (他们是粉丝页面上的公开帖子。)
Array
(
[message] => #cpchickenbreast
[created_time] => 2015-09-01T07:14:48+0000
[id] => 148902108457774_819236841508190
)
代码
$fb = new Facebook\Facebook([
'app_id' => FACEBOOK_APP_ID,
'app_secret' => FACEBOOK_SECRET,
'default_graph_version' => 'v2.4',
]);
$accessToken = FACEBOOK_APP_ID.'|'.FACEBOOK_SECRET;
$fb->setDefaultAccessToken($accessToken);
$pagefeed = $fb->get("/" . $pageid . "/tagged?limit=3");
foreach($pagefeed->getDecodedBody() as $posts) {
foreach($posts as $post) {
print_r($post);
}
}
使用v3,我可以获取Feed,只需访问"输入"数据知道它是一张图片,并且可以与"图片"数据
[id] => 148902108457774_1133014613379847
[from] => Array
(
[name] => XXXXXXXXXXXXXX
[category] => Food/Beverages
[category_list] => Array
(
[0] => Array
(
[id] => 2252
[name] => Food/Beverages
)
)
[id] => 148902108457774
)
[message] => xxxxxxxxxxxxxxxxxxxxxxxxxxxx
[story] => xxxxx
[story_tags] => Array
(
)
[picture] => https://scontent.xx.fbcdn.net/hphotos-xfp1/v/t1.0-9/s130x130/11885212_1899706113588729_9156711625894648877_n.png?oh=c98d05c819ce00da8515f04eb7cf9227&oe=5660CFC3
[link] => https://www.facebook.com/cpbalance/photos/a.1841153286110679.1073741828.1794977444061597/1899706113588729/?type=1
[name] => XXXXXXXXXXXXXXXXXXx .... and a lot more
答案 0 :(得分:1)
$session_token = Session::get('facebook_access_token');
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.4'
]);
$fb->setDefaultAccessToken($session_token);
$responseTagged = $fb->get('/me?fields=tagged.limit(10){id,message}');
$taggedNode = $responseTagged->getGraphNode();
$taggeds = $taggedNode['tagged'];
foreach ($taggeds as $tagged) {
print_r($tagged['message']);
print_r('<br>');
}