Facebook Graph API - 获得页面/群组照片的点赞数 [英] Facebook Graph API - Get like count on page/group photos

查看:21
本文介绍了Facebook Graph API - 获得页面/群组照片的点赞数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在测试图形 API 并遇到了问题.如何从页面/群组的照片中获得点赞数?

I've been testing graph API and ran into a problem. How can I get like count from photos of a page/group?

我是群组的管理员/创建者.当输入 https://developers.facebook.com/tools/explorer/ 某些照片 ID 时它带来了来自该组的几乎所有数据,甚至是评论,但不包括点赞数.对于类似的部分,它需要(根据文档)访问令牌,尽管任何人都可以访问该信息.

I'm administrator/creator of a group. When entering in https://developers.facebook.com/tools/explorer/ certain photo ID from that group it brings almost all data, even comments, but not the like count. For like part it needs (according to docs) access token despite the fact that anyone can access that info.

如何获取具有所需权限的页面/组的访问令牌以及如何使用它来获取我需要的信息?

How to get access token of my page/group with required permissions and how to use it to get info I need?

如果可能的话,我想从单个地址获取 JSON.

If possible I would like to get JSON from a single address if it is possible.

推荐答案

这可以通过页面实现(即使没有访问令牌!),方法如下:

This is possible with a page (even without an access token!) and here's how:

访问图表上的页面

通过访问页面的 url 来获取页面的 id:

Get the page's id by going to the page's url:

https://www.facebook.com/pages/platform/19292868552

URL 末尾的数字是页面的 id.获取该 ID 并将其与图形浏览器一起使用(此处)或直接访问它直接.

The number on the end of the URL is the page's id. Take that id and use it with the graph explorer (here) or just visit it directly.

访问页面相册

现在将相册附加到该网址将为您提供该页面的所有相册,包括墙上的照片:

Now appending albums to that url will give you all the albums the page has, including wall photos:

https://graph.facebook.com/19292868552/albums

输出如下:

{
   "data": [
      {
         "id": "10150160810478553",
         "from": {
            "name": "Facebook Platform",
            "category": "Product/service",
            "id": "19292868552"
         },
         "name": "Bringing Operation Developer Love to Europe",
         "description": "Blog post: http://developers.facebook.com/blog/post/479

Videos and presentations uploaded here: http://developers.facebook.com/videos/",
         "location": "Berlin, Paris, London",
         "link": "https://www.facebook.com/album.php?fbid=10150160810478553&id=19292868552&aid=285301",
         "cover_photo": "10150160811078553",
         "count": 32,
         "type": "normal",
         "created_time": "2011-04-06T23:05:44+0000",
         "updated_time": "2011-04-06T23:33:20+0000",
         "comments": {
         ..... etc ....

选择相册

对于data 数组中的每个对象,都有一个id 和一个名称.使用这两个字段,您可以选择包含所需照片的相册.这个结果的第一张专辑是将运营开发者的爱带到欧洲".让我们看看这张专辑的照片.

For each object in the data array there is an id and a name. Using these two fields you can select the album that contains the photos you want. The first album in this result is "Bringing Operation Developer Love to Europe". Lets look at this albums photos.

看照片

如果到目前为止您已经按照答案进行操作,那么下一步应该是相当明显的.使用id作为您想要的相册并将照片附加到图表网址:

If you've followed the answer up to this point the next step should be fairly obvious. Use the id for the album you want and append photos to the graph url:

https://graph.facebook.com/10150160810478553/photos

看到照片的赞

很像选择相册,只需在上述步骤的输出中使用 id 并将 likes 附加到 url 即可查看喜欢的照片:

Much like selecting an album, simply use an id in the output of the above step and append likes to the url to see a photos likes:

https://graph.facebook.com/10150160813853553/likes

输出:

{
   "data": [
      {
         "id": "1163036945",
         "name": "Aditya Pn"
      },
      {
         "id": "1555885347",
         "name": "Nadin Mu00f6ller"
      },
      {
         "id": "100001643068103",
         "name": "Umut Aygu00fcn"
      },
      {
         "id": "100000165334510",
         "name": "Alessandra Milfont"
      },
      {
         "id": "100001472353494",
         "name": "Sayer Mohammad Naz"
      },
      {
         "id": "1051008973",
         "name": "Jenson Daniel Chambi"
      },
      {
         "id": "100000233515895",
         "name": "Ruby Atiga"
      },

使用此输出,您可以简单地计算数据数组中的条目数以获得点赞数.

Using this output you can simply count the number of entries in the data array to get the like count.

请注意,使用图形浏览器,点击输出框中的 id连接侧边栏(除了最后一个/likes 连接,希望很快会添加.我希望这会有所帮助.此外,您不需要访问令牌来执行任何这些操作,因为页面是公开的.希望这有帮助!

Note that all of this is possible from using the graph explorer by clicking on ids in the output box and the connections sidebar (except for the last /likes connection, which will hopefully be added soon. I hope this helps. Also, you do not need an access token to do any of this because pages are public. Hope this helps!

这篇关于Facebook Graph API - 获得页面/群组照片的点赞数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆