如何在Facebook上获得帖子的“赞”数?
我收到一条链接graph.facebook.com/userid_postid
,上面写着说我可以这样做。但是如何查找用户或页面ID以及帖子的ID?
例如,如果在粉丝页面上刊登任何帖子: 网站http://www.facebook.com/tipscow
的http://tipscow.com如果我在上面的粉丝页面上发帖,并且有人喜欢这个帖子,我该如何获得该帖子的喜欢数量?我希望将该号码显示在另一个网站上。
答案 0 :(得分:3)
您可以使用FQL
SELECT like_info.like_count, share_info.share_count, comment_info.comment_count FROM stream WHERE post_id = 'your_post_id'
答案 1 :(得分:1)
您可以使用/<PAGE_ID>/posts
获取粉丝页面的最新帖子列表(您可以通过导航到http://graph.facebook.com/myown.easytipsandtricks
找到您的页面,或只使用用户名)并使用有效访问权限令牌。从那里,你得到一个如下所示的对象:
"data": [
{
"id": "22092443056_115909438544849",
"from": {
"name": "Starbucks",
"category": "Food/beverages",
"id": "22092443056"
},
// ...
"shares": {
"count": 708
},
"likes": {
"data": [
{
"name": "Shanna Gonzales",
"id": "100000244536406"
}
],
"count": 17129
},
"comments": {
"count": 759
}
}
// ... and more posts
访问每个字段的count
子字段应分别告诉您分享,赞和评论。
答案 2 :(得分:0)
您可以通过将fields参数与likes.limit(1).summary(true)
结合使用来获取评论/喜欢计数而无需分页。例如,下面的披萨搜索api查询将为您提供所有公开帖子及其喜欢的计数总结:
https://graph.facebook.com/search?q=pizza&type=post&fields=id,name,likes.limit(1).summary(true)
结果(截断):
{
"data": [
{
"id": "47883936273_659693910762305",
"name": "Instagram",
"created_time": "2014-02-16T01:15:29+0000",
"likes": {
"data": [
{
"id": "100002243084532",
"name": "Yvette Martin"
}
],
"paging": {
"cursors": {
"after": "MTAwMDAyMjQzMDg0NTMy",
"before": "MTAwMDAyMjQzMDg0NTMy"
},
"next": "https://graph.facebook.com/47883936273_659693910762305/likes?limit=1&summary=1&after=MTAwMDAyMjQzMDg0NTMy"
},
"summary": {
"total_count": 13682
}
}
},
{
"id": "136336876521150_314001148754721",
"name": "Pizza Box Turns into Plates & Storage Unit!",
"created_time": "2014-02-15T21:20:00+0000",
"likes": {
"data": [
{
"id": "100005373008864",
"name": "Liliana Campoli"
}
],
"paging": {
"cursors": {
"after": "MTAwMDA1MzczMDA4ODY0",
"before": "MTAwMDA1MzczMDA4ODY0"
},
"next": "https://graph.facebook.com/136336876521150_314001148754721/likes?limit=1&summary=1&after=MTAwMDA1MzczMDA4ODY0"
},
"summary": {
"total_count": 2792
}
}
}