Facebook Graph API:获取帖子/状态附加照片 [英] Facebook Graph API: Get post/status attached photos

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

问题描述

如何获取一组帖子/状态的多个附件?

例如:某个成员撰写并添加了多张照片的群组状态..

目前我正在使用 Graph api 获取 group_id/feed 的组流,但无法看到附加到单个状态的图像 - 在从 Facebook 本身访问 feed 时,我可以验证附加到状态的照片很少.

使用 FQL 可以通过以下查询获取附件:

从流中选择附件 post_id = each_post_id

考虑到我必须在每个帖子中发送此请求并且 FQL 很快就会消失,我正在寻找替代方案.

解决方案

我也在为此寻找解决方案,实际上刚刚找到.

Facebook 平台变更日志如下:

<块引用>

/v2.1/{post-id} 现在将返回附加到帖子的所有照片:在以前版本的 API 仅返回第一张照片并带有邮政.这样就无需使用 FQL 来获取帖子的所有照片.

有了这些知识,我去了 Graph Api Explorer 并找到了一个帖子,其中有 2添加附件或更多附件.

在找到帖子和帖子 ID 后,我尝试了 Facebook 让我执行的请求:

<块引用>

/v2.1/{post_id}

这不会给您想要的结果.资源管理器的好处是您可以搜索要添加到请求中的字段.

您要添加附件(复数)字段.注意:图形 API 资源管理器可能只显示 attachment(单数)字段.这是不对的.

总结一下:

  1. 获取包含图片的帖子的帖子 ID.
  2. 创建一个对图形 API 的新请求,类似于:/v2​​.1/{post_id}?fields=attachments

然后阅读结果以获得您想要的附件.

希望这对你有所帮助,因为我也已经挣扎了一段时间了.

韩国

PS:这个是用用户测试的,不是用组测试的,但是应该基本一样.
PS2:这只是对如何获取单个帖子的附件的说明.您还可以将 attachments 字段添加到 /me/home egde 以立即获取每个帖子的所有附件,如下所示:

<块引用>

me/home?fields=message,from,attachments

PS3:您需要的权限是

<块引用>

  1. 用户状态
  2. 读取流
  3. 用户照片
  4. user_videos

Facebook 在这件事上不是很清楚,而且很难弄清楚这样的事情.所以我希望这能帮助所有正在寻找此解决方案的人.

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..

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.

Using FQL it is possible to get the attachments with the following query:

SELECT attachment FROM stream WHERE post_id = each_post_id

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.

The Facebook Platform changelog says the following:

/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.

With this knowledge I went to the Graph Api Explorer and found a post that had 2 attachments or more added to it.

After finding the post, and with that the post id, I tried the request Facebook told me to do:

/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.

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.

So, to summarize:

  1. Get the post id of the post containing the images.
  2. Create a new request to the graph api that looks something like: /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: 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:

me/home?fields=message,from,attachments

PS3: The permissions you need are

  1. user_status
  2. read_stream
  3. user_photos
  4. user_videos

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屋!

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