Facebook Graph API:获取帖子/状态附加的照片 [英] Facebook Graph API: Get post/status attached photos
问题描述
如何在组中获得多个附件的帖子/状态?
How can one get multiple attachments of a post/status in a group?
例如:某个成员写入并添加多张照片的组状态
For example: A group status that some member wrote and added multiple photos to..
目前,我正在使用Graph api来获取group_id / feed的组流,并且无法查看附加到单个状态的图像 - 从Facebook本身访问Feed可以验证状态附近有几张照片。
Currently I am using Graph api to get the group stream with group_id/feed and unable to see images attached to a single status - while accessing the feed from Facebook itself I can validate that there are few photos attached to the status.
使用FQL可以使用以下查询获取附件:
Using FQL it is possible to get the attachments with the following query:
SELECT attachment FROM stream WHERE post_id = each_post_id
SELECT attachment FROM stream WHERE post_id = each_post_id
考虑到我将不得不发送每个帖子的请求,FQL很快就会消失,我正在寻找一个
Considering I will have to send this request per post and that FQL will soon be gone I am searching for an alternative.
推荐答案
我正在寻找一个解决方案,实际上只是找到了。
I was looking for a solution for this as well and actually just found it.
Facebook Platform changelog 说如下:
/v2.1/ {post-id}现在将返回附加到帖子的所有照片:
以前版本的API只有第一张照片返回一个
的帖子。这消除了使用FQL获取所有帖子的照片的需要。
/v2.1/{post-id} will now return all photos attached to the post: In previous versions of the API only the first photo was returned with a post. This removes the need to use FQL to get all a post's photos.
有了这个知识,我去了一个 Graph Api Explorer ,并找到一个添加了2个附件的帖子。
With this knowledge I went to the Graph Api Explorer and found a post that had 2 attachments or more added to it.
找到帖子后,发贴号,我尝试了Facebook告诉我要做的请求:
After finding the post, and with that the post id, I tried the request Facebook told me to do:
/v2.1/ {post_id}
/v2.1/{post_id}
这不给你所需的结果。关于浏览器的好处是,您可以搜索要添加到请求中的字段。
This does NOT give you the desired result. The nice thing about the explorer is that you can search for fields you want to add to your request.
您要添加附件复数)字段。注意:可能图形api资源管理器仅显示附件(单数)字段。这是不对的。
You want to add the attachments (plural) field. NOTE: It might be that the graph api explorer only shows the attachment (singular) field. This is NOT right.
所以,总结一下:
- 获取帖子
- 向图api创建一个新的请求,如下所示:/v2.1/ {post_id}?fields = attachments
然后阅读结果以获取所需的附件。
Then read the result to get your desired attachments.
我希望这可以帮助您,因为我一直在努力一段时间。
I hope this helps you out as I have been struggling for a while as well.
KR
PS:这是用户测试的,而不是一个组,但它应该基本相同。
PS2:这只是一个解释如何获得单个帖子的附件。您还可以将附件字段添加到 / me / home egde中,以便在每个帖子中立即获取所有附件:
PS: This is tested with a user and not a group, but it should be basically the same.
PS2: This is just an explanation of how you get attachments of a single post. You can also add the attachments field to the /me/home egde to immediately get all attachments at every post like so:
我/ home?fields = message,from,附件
me/home?fields=message,from,attachments
PS3:权限你需要是
PS3: The permissions you need are
- user_status
- read_stream
- user_photos
- user_videos
- user_status
- read_stream
- user_photos
- user_videos
Facebook在这件事上不是很清楚,很难想像这样的事情。所以我希望这将帮助所有寻求这个解决方案的人。
Facebook is not very clear on this matter and it is very hard to figure things out like this. So I hope this will help everyone that is searching for this solution.
这篇关于Facebook Graph API:获取帖子/状态附加的照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!