我目前正在使用以下代码在我们的网站上显示facebook群组页面帖子:
<?php
$limit = 10; // The number of posts fetched
$access_token = 'enter token here';
$group_id = '3573401125';
$url1 = 'https://graph.facebook.com/'.$group_id.'?access_token='.$access_token;
$des = json_decode(file_get_contents($url1));
/**echo '<pre>';
print_r($des);
echo '</pre>';**/
$url2 = "https://graph.facebook.com/{$group_id}/feed?access_token={$access_token}";
$data = json_decode(file_get_contents($url2));
//print_r($data);
?>
<div class="wrapperfb">
<!--<legend class = "dashheadlinetitle">Millbrook RFC Facebook Group</legend>-->
<div class="topfb">
<a class="afb" href='http://www.facebook.com/home.php?sk=group_<?=$group_id?>&ap=1'>
<?=$des->name?> Facebook Group</a>
<div style="width:100%; margin: 5px">
</div>
</div>
<?php
$counter = 0;
foreach($data->data as $d) {
if($counter==$limit)
break;
?>
<div class="singlefb">
<div class="imgfb">
<a class="afb" href="http://facebook.com/profile.php?id=<?$d->from->id?>">
<img border="0" alt="<?=$d->from->name?>" src="https://graph.facebook.com/<?=$d->from->id?>/picture"/>
</a>
</div>
<div class="textfb">
<span style="font-weight:bold">
<a class="afb" href="http://facebook.com/profile.php?id=<?=$d->from->id?>"><?=$d->from->name?></a>
</span>
<br/>
<span style="color: #999999;">on <?=date('F j, Y H:i',strtotime($d->created_time))?></span>
<br/>
<a class="msglink" href="https://www.facebook.com/groups/3573401125/"><?=$d->message?></a>
</div>
</div>
<?php
$counter++;
}
?>
这可以很好地向我展示该组的最新帖子。我搜索了FB开发者网站并使用谷歌,但似乎无法找到一种方法来提出每篇文章的评论。
我有办法做到这一点吗?
答案 0 :(得分:0)
我认为您必须对返回https://graph.facebook.com/12345/comments/?summary=true的每个帖子提出请求,其中12345
是post_id。
一些伪代码来解释我的意思:
posts = fetchPostsFromFacebook(group_id)
foreach (posts as post)
post_comments = fetchComments(post.id)