Facebook Graph API - 获得像页面/组照片一样 [英] Facebook Graph API - Get like count on page/group photos

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

问题描述

我一直在测试图形API,遇到一个问题。我如何从一个页面/组合的照片中获得数量?



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



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



如果可能,我想从单一地址获取JSON。

解决方案

这是可能的一个页面(即使没有访问令牌!)和以下方式:



访问图表上的页面



通过访问页面的URL来获取页面的ID:



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



网址末尾的编号是网页的ID。拿这个ID,并使用图形资源管理器(这里)或只是访问它直接



访问页面的相册



现在将相册附加到该网址会给您该页面的所有相册包括墙壁照片:



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



输出如下所示:

  {
data:[
{
id:10150160810478553,
from:{
name :Facebook平台,
类别:产品/服务,
id:19292868552
},
名称:引导操作开发人员爱欧洲,
描述:博客文章:http://developers.facebook.com/blog/post/479\\\
\\\
在这里上传的视频和演示文稿:http://developers.facebook .com / videos /,
location:Berlin,Paris,London,
link:https://www.facebook.com/album.php?fbid=101501608104785 53& 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:{
.....等....

选择相册



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



看照片



接下来的答案到此为止,下一步应该是相当明显的。使用您想要的相册的 ID ,并将照片附加到图形网址:



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



看到照片喜欢



就像选择相册一样,只需在上述步骤的输出中使用ID,并附加喜欢到网址看到喜欢的照片:



https://图。 facebook.com/10150160813853553/likes



输出:

  {
data:[
{
id:1163036945,
name:Aditya Pn
},
{
id:1555885347,
name:Nadin M\\\öller
},
{
id:100001643068103 ,
name:Umut Ayg\\\ün
},
{
id:100000165334510,
name:Alessandra Milfont
},
{
id:100001472353494,
name:Sayer Mohammad Naz
},
{
id:1051008973,
name:Jenson Daniel Chambi
} ,
{
id:100000233515895,
name:Ruby Atiga
},

使用此输出,您可以简单地计算数据数组中的条目数以获得类似的计数。






请注意,所有这些都可以通过使用图形资源管理器点击输出框中的ids和连接侧边栏(除了以外的最后/喜欢的连接,这将很快被添加。我希望这有帮助。此外,您不需要访问令牌来执行任何操作,因为页面是公开的。希望这有帮助!


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

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?

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:

Visit the page on the graph

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

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

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.

Visit the page's albums

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

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

The output looks like this:

{
   "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\n\nVideos 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 ....

Selecting an album

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.

Seeing Photos

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

Seeing a Photo's likes

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

Output:

{
   "data": [
      {
         "id": "1163036945",
         "name": "Aditya Pn"
      },
      {
         "id": "1555885347",
         "name": "Nadin M\u00f6ller"
      },
      {
         "id": "100001643068103",
         "name": "Umut Ayg\u00fcn"
      },
      {
         "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.


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天全站免登陆