最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to get only photos from user's Facebook newsfeed using graph api? - Stack Overflow

programmeradmin0浏览0评论

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

=

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?

I bed 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./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?

Share Improve this question asked Dec 17, 2011 at 5:35 TMCTMC 8,15412 gold badges55 silver badges74 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

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./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./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 has added a filter parameter to the /me/home endpoint so if you query /me/home?filter=photos you get only photos from the users News Feed

发布评论

评论列表(0)

  1. 暂无评论