Facebook Graph API: How to filter home & feed by application?

前端 未结 3 1302
梦毁少年i
梦毁少年i 2020-12-09 07:08

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?

3条回答
  •  执念已碎
    2020-12-09 07:49

    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.

提交回复
热议问题