简体   繁体   中英

How to get only photos from user's Facebook newsfeed using graph api?

I combed through the Facebook documentation but didn't see an obvious way to return ONLY photos on a user's newsfeed. Specifically:

Give a FB access token, I want to get the newsfeed filtered to only photos that were posted.

https://graph.facebook.com/me/home?access_token=

Returns the entire newsfeed. I see that elements have a "Type" attribute, that has a value of "photo" when it's a photo.

How can I scope the response to only return photos?

Sure, you can do this using FQL:

SELECT 
    post_id, message, attachment 
FROM 
    stream 
WHERE 
    filter_key 
IN (
    SELECT 
        filter_key 
    FROM 
        stream_filter 
    WHERE 
        uid = me() 
    AND 
        name = "Photos"
   )

Working demo using Graph API Explorer: https://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20post_id%2C%20message%2C%20attachment%20FROM%20stream%20WHERE%20filter_key%20IN%20(SELECT%20filter_key%20FROM%20stream_filter%20WHERE%20uid%3Dme()%20AND%20name%3D%22Photos%22)

EDIT:

Looks like that link won't work. This is the request to the graph api. You need read_stream permissions.

https://graph.facebook.com/fql?q=SELECT post_id, message, attachment FROM stream WHERE filter_key IN (SELECT filter_key FROM stream_filter WHERE uid=me() AND name="Photos")

Facebook已经增加了一个过滤器参数来/me/home endpoint ,所以如果你查询/me/home?filter=photos你从用户只能照片News Feed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM