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

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

问题描述

我一直在测试图形API并遇到了问题。我如何从一个网页/群组的照片中计数?



我是群组的管理员/创建者。在 https://developers.facebook.com/tools/explorer/ 中输入来自该组的某些照片ID时几乎所有的数据,甚至评论,但不是计数。



如何获取我的页面/组的访问令牌所需的权限(根据文档)访问令牌,尽管任何人都可以访问该信息。以及如何使用它来获取我需要的信息?



如果可能,我希望从一个地址获取JSON。

解决方案

这是可能的页面(即使没有访问令牌!)和以下是如何:



访问图表上的页面



通过访问网页的网址获取网页的ID:



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



网址末尾的数字是网页的ID。使用该ID,并将其与图形资源管理器(此处)一起使用,或者只是访问它直接



访问网页的相册



现在将相册附加到该网址网页上的所有相册,包括墙壁照片:



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



输出如下所示:

  {
data:[
{
id:10150160810478553,
from:{
:Facebook Platform,
category:Product / service,
id:19292868552
},
name:爱上欧洲,
description:博客文章:http://developers.facebook.com/blog/post/479\\\
\\\
Videos和presentations upload here:http://developers.facebook .com / videos /,
location:柏林,巴黎,伦敦,
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 ....

选择相册 / p>

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


$ b

查看照片



跟着回答到这一点,下一步应该是相当明显的。使用所需的相簿 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天全站免登陆