Facebook Graph API:如何过滤主页和主页按应用程序馈送?

发布于 2024-12-12 06:36:46 字数 92 浏览 1 评论 0 原文

Facebook Graph API 可让您获取主页(新闻源)和主页的 JSON 表示形式。饲料(墙)。

如何获取 Facebook 应用程序发布的帖子?

The Facebook Graph API lets you grab a JSON representation of home (News Feed) & feed (Wall).

How do I just get the posts made by my Facebook app?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱情眠于流年 2024-12-19 06:36:46

Facebook 添加了对过滤 me/home 帖子的支持,无需使用 FQL,只需传递 filter 参数即可。

例如,要仅获取照片,您可以执行以下操作:
me/home?filter=app_2305272732

完整文档位于:http:// Developers.facebook.com/docs/reference/api/user/#home

Facebook has added support to filter me/home posts without using FQL by passing the filter parameter.

For example to get just photos you can do:
me/home?filter=app_2305272732

Full documentation is here: http://developers.facebook.com/docs/reference/api/user/#home

聚集的泪 2024-12-19 06:36:46

您现在可以使用 Facebook 查询语言 (FQL) 查询“https://developers.facebook.com/docs/reference/api/” rel="nofollow noreferrer">Facebook Graph API(基本 URL:https://graph.facebook.com)。

假设您的应用程序是 Twitter。 Twitter 的 Facebook 应用程序 ID 是 2231777543。

我在 @danontheline 的回答并仔细阅读 Facebook 的文档 FQL 流 & FQLstream_filter

以下摘录特别相关:

如果您从 stream_filter FQL 表指定 filter_key
多个用户,返回的结果将类似于用户的主页
新闻提要。如果仅指定一个用户作为 source_id,您将
接收用户或页面的个人资料视图。你可以过滤这些
通过指定 filter_key 'others'(仅返回
由除指定用户)或“所有者”之外的其他人发布的帖子
(仅返回指定用户发布的帖子)。个人资料视图,
与主页视图不同,它返回来自我们数据库的旧数据。在
对于主页来说,个人资料视图还包括粉丝的帖子。

Facebook 新闻源上的 Twitter 推文

GET /fql?q=SELECT post_id, actor_id, message, app_id, attribution FROM stream WHERE filter_key = 'app_2231777543'

Facebook 墙上的 Twitter 推文

GET /fql?q=SELECT post_id, actor_id, message, app_id, attribution FROM stream WHERE source_id = me() AND app_id = '2231777543' LIMIT 1000

使用 Facebook Graph API Explorer 返回 Facebook Graph API post 对象(结果集会有所不同,具体取决于在access_token、隐私等)。您可以通过将流表的其他列添加到上面的查询中和/或简单地向每个 post_id< 的 GET /{post_id} 发出另一个 Graph API 请求来了解有关每个帖子的更多信息。 /code> 由上面的 FQL 流查询返回。

You can now run Facebook Query Language (FQL) queries using the Facebook Graph API (base URL: https://graph.facebook.com).

Let's say your application is Twitter. Twitter's Facebook application ID is 2231777543.

I came up with the FQL queries below with the help of @danontheline's answer and by carefully reading Facebook's documentation on FQL stream & FQL stream_filter.

The following excerpt is particularly pertinent:

If you specify a filter_key from the stream_filter FQL table or
multiple users, results returned will behave like the user's homepage
news feed. If only one user is specified as the source_id, you will
receive the profile view of the user or page. You can filter these
profile view posts by specifying filter_key 'others' (return only
posts that are by someone other than the specified user) or 'owner'
(return only posts made by the specified user). The profile view,
unlike the homepage view, returns older data from our databases. In
the case of a Page, the profile view also includes posts by fans.

Twitter Tweets on Your Facebook News Feed

GET /fql?q=SELECT post_id, actor_id, message, app_id, attribution FROM stream WHERE filter_key = 'app_2231777543'

Twitter Tweets on Your Facebook Wall

GET /fql?q=SELECT post_id, actor_id, message, app_id, attribution FROM stream WHERE source_id = me() AND app_id = '2231777543' LIMIT 1000

Running these queries with the Facebook Graph API Explorer returns Facebook Graph API post objects (The result set will differ depending on access_token, privacy, etc.). You can find out more about each post by adding other columns of the stream table to the queries above and/or by simply making another Graph API request to GET /{post_id} for eache post_id returned by the FQL stream queries above.

み零 2024-12-19 06:36:46

老实说,仅使用 Graph API 是不可能实现这一点的。但是您也可以使用 FQL 语句来检索墙/提要。通过这种技术,您可以将其限制为由一个 actor_id(在本例中应该是您的应用程序 ID)发布的帖子:

SELECT post_id, target_id, message FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0 AND actor_id = 'MattDiPasqualesAppID'

这里的问题是它不会返回 JSON,而是返回结果的 XML 表示形式。使用 phps DOM 类,您可以轻松地将其转换为 JSON 格式或您想要的结果的任何其他表示!

由于您可能会使用 PHP 处理整个事情,因此您也可以只获取 json 数组,将其解析为数组并使用 appID 的键过滤该数组。

Afaik thats not possible with just the Graph API. But you can just use a FQL statement to retrieve the wall/feed, too. With this technique you are able to resrict it to the posts made by one actor_id (which should be your app ID in this case):

SELECT post_id, target_id, message FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0 AND actor_id = 'MattDiPasqualesAppID'

Thing here is that it won't return a JSON, but a XML representation of the result. With phps DOM class you are easily able to convert it into a JSON format or any other representation you want to have of the result!

As you might be handling the whole thing with PHP anyway, you also could just take the json array, parse it into an array and filter the array with keys of your appID.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文