Facebook图表api需要一个页面的照片? [英] Facebook graph api call for a page's photos?

查看:89
本文介绍了Facebook图表api需要一个页面的照片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Facebook的图形API来检索页面的照片。以下是我使用的电话:

I want to use facebook's graph api to retrieve a page's photos. Here's the call I'm using:

'https://graph.facebook.com/'. $pageID .'/photos?access_token='. $page_access_token

由于某种原因,此调用返回一个空数据集。我正在使用页面访问令牌而不是用户,用户是我正在尝试从中检索照片的页面的管理员。页面ID是正确的,因为当我使用此调用来获取页面的事件时,它的工作正常。我使用错误的电话?

For some reason this call returns an empty data set. I am using a page access token not an users, and the user is the admin of the page I'm trying to retrieve photos from. The page ID is correct since when I use this call to get the page's events it works well. Am I using the wrong call?

推荐答案

有时你不幸遇到使用FQL调用来获取这种类型的信息。 Facebook与页面数据的处理方式有很大的不一致性 - 我不会理解这些内容,但您可以在这里找到您想要做的内容:如何使用Facebook图表API来检索风扇照片上传到墙壁的风扇页面?

Sometimes you're unfortunately stuck using FQL calls to get this type of information. Facebook has a lot of inconsistencies with how page data is handled -- I won't get into these, but what you're looking to do can be found here: How to use Facebook graph API to retrieve fan photos uploaded to wall of fan page?

这是一个PHP示例:

    $photoQuery = urlencode('SELECT pid,owner,src_small,src_big FROM photo WHERE aid IN ( SELECT aid  FROM album  WHERE owner = your_page_id)');    
    $photoFQL = 'https://api.facebook.com/method/fql.query?query='.$photoQuery .'&access_token='.$accessToken.'&format=json';   
    $photoResults = file_get_contents($photoFQL);

你最终会得到一个你可以测试的URL:

You'll end up with a url like this you can test with:

https://api.facebook.com/method/fql.query?query = SELECT%20pid%2Cowner%2Csrc_small%2Csrc_big%20FROM%20photo%20WHERE%20aid%20英寸20%(%20SELECT%20aid%20%20FROM%20album%20%20WHERE%20owner%20%3D% {PAGE_ID })& access_token = {access_token}& format = json

https://api.facebook.com/method/fql.query?query=SELECT%20pid%2Cowner%2Csrc_small%2Csrc_big%20FROM%20photo%20WHERE%20aid%20IN%20(%20SELECT%20aid%20%20FROM%20album%20%20WHERE%20owner%20%3D%{page_id})&access_token={access_token}&format=json

当然,用你自己的代替{page_id}和{access_token}在JSON响应中显示了我的社区/粉丝专页的照片,祝你好运。

Replacing the {page_id} and {access_token} with your own, of course. I tested this and it showed my Community/Fan Page's photos in a JSON response. Good luck.

这篇关于Facebook图表api需要一个页面的照片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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