简体   繁体   English

如何使用新的Graph API(v2.4)获取Facebook页面的总喜欢数

[英]How to get Facebook page total likes number with the new Graph API (v2.4)

So recently there was a update to the Facebook Graph API and now pretty much everything requires a access_token to retrieve any type of data. 因此,最近对Facebook Graph API进行了更新,现在几乎所有内容都需要一个access_token来检索任何类型的数据。

Previously you could get the number of page likes by accessing the graph like so: 以前,您可以通过如下方式访问图表来获得喜欢页面的数量:

http://graph.facebook.com/{page-name}

But now if you try it says you need to have a access token because of a recent update to the API. 但是现在,如果您尝试使用它,则表明由于API的最新更新,您需要具有访问令牌。 Now the issue i am having is i cant access the likes even with an access token this is the response i am getting: 现在我遇到的问题是即使使用访问令牌也无法访问喜欢的对象,这是我得到的响应:

Request 请求

http://graph.facebook.com/{page-name}/?access_token={access_token}

Response 响应

array(2) {
    ["name"] "Page Name"
    ["id"] "Page Id"
} 

Now at first i thought the access token wasn't being generated with the correct scopes but i am 99% sure you only need read_stream to pull that type of data. 现在,起初我以为访问令牌不是使用正确的作用域生成的,但是我99%确信您只需要read_stream即可提取该类型的数据。

Second thought is that they have removed the ability to acces likes of any page and you need a page token to receive that type of data or finally i am missing something incredibly small here and its still achievable? 第二个想法是,他们已经删除了访问喜欢任何页面的功能,并且您需要页面令牌才能接收该类型的数据,或者最终我在这里缺少了难以置信的小东西并且仍然可以实现?

So my question is can you still get the number of likes of any page using the Facebook Graph API and if the answer is yes how do you do it? 所以我的问题是,您仍然可以使用Facebook Graph API获得任何页面的点赞次数吗?如果答案是肯定的,您该怎么做?

any help appreciated 任何帮助表示赞赏

The Graph API v2.4 reduces the number of fields in default responses. Graph API v2.4减少了默认响应中的字段数。

https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/ https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/

Fewer default fields for faster performance: To help improve performance on mobile network connections, we've reduced the number of fields that the API returns by default. 较少的默认字段可提高性能:为了帮助提高移动网络连接的性能,我们减少了API默认返回的字段数。 You should now use the ?fields=field1,field2 syntax to declare all the fields you want the API to return. 现在,您应该使用?fields=field1,field2语法声明要让API返回的所有字段。

If you do ?fields=likes it should show up. 如果执行?fields=likes应该会显示。

您可以这样:

https://graph.facebook.com/v2.4/{page_id}/fields=likes

This can help you! 这可以帮助您! Just add ?fields=likes after the page name/id. 只需在页面名称/ id之后添加?fields = likes。 You can use any access token for fetching data! 您可以使用任何访问令牌来获取数据!

graph.facebook.com/{page_name}?fields=likes&access_token={token}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用新的Facebook graph API v2.4从页面获取事件 - How to get events from a page with the new facebook graph api v2.4 Facebook API图形v2.4获取简单数据 - Facebook api graph v2.4 get simple data 如何从 facebook graph php api v2.6 获取总页面赞 - How to get total page likes from facebook graph php api v2.6 获得全部评论,赞,分享(PHP Facebook API v2.4) - Get Total Comment, Like, Share (PHP Facebook API v2.4) 使用graph API v2.4及更高版本获取Facebook新闻提要 - Get facebook news feed using graph api v2.4 and above Facebook iOS SDK - 在Graph API v2.4中获取好友列表 - Facebook iOS SDK - get friends list in Graph API v2.4 在 FaceBook Graph API v2.4 中,如何在 JSON 提要中包含帖子的图片/图标? - In FaceBook Graph API v2.4, how can I include pictures/icons of the posts in the JSON feed? 如何在Facebook API v2.4及更高版本上获取收件人ID(RestFB / Facebook4J) - How to get the recipient ID on Facebook API v2.4 and newer (RestFB/Facebook4J) 如何确定Facebook API v2.4中的事件隐私? - How to determine event privacy in Facebook API v2.4? 在Android中,Facebook API V2.4不返回电子邮件ID,而V2.3返回。 如何在V2.4中获取电子邮件ID? - In Android, Facebook API V2.4 is not returning email id whereas V2.3 is returning. How to get email id in V2.4?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM