简体   繁体   English

如何使用图形API从用户的Facebook新闻源中仅获取照片?

[英]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. 我浏览了Facebook文档,但没有找到一种明显的方法来仅返回用户新闻源中的照片。 Specifically: 特别:

Give a FB access token, I want to get the newsfeed filtered to only photos that were posted. 给一个FB访问令牌,我希望将新闻提要过滤为仅发布的照片​​。

https://graph.facebook.com/me/home?access_token= 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: 当然,您可以使用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) 使用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) : 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) fql%3Fq%3DSELECT%20post_id%2C%20message%2C%20attachment%20FROM%20stream%20WHERE%20filter_key% 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. 这是对图api的请求。 You need read_stream permissions. 您需要read_stream权限。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Facebook Graph API(Javascript)从页面的照片中获取图像的URL - Get image's URL from page's photos using Facebook Graph API (Javascript) 使用Facebook Graph API获取用户朋友的列表 - Using the Facebook Graph API to get a list of a user's friends 在JavaScript中使用Facebook API获取测试用户的照片 - Get photos of Test User using Facebook API in javascript 如何通过Facebook Graph Api获取用户朋友生日那天在用户墙上发布的帖子? - How to get posts that user's friend posted on the wall of user on his birthday through Facebook Graph Api? 如何使用 Microsoft Graph API 获取用户的照片(个人资料)? - How to get user's photo(profile) using Microsoft Graph API? facebook graph API:无法获取用户朋友列表 - facebook graph API: not able to get a list of user's friends 您是否可以使用Graph API获取公共Facebook页面的订阅源而无需要求用户允许? - Can you get a public Facebook page's feed using Graph API without asking a user to allow? 如何从 Facebook chatbot api 获取用户的位置 - How to get user's location from Facebook chatbot api 使用Facebook图形API发布到未经身份验证的用户的墙上 - Posting to an unauthenticated user's wall using the facebook graph api 从 Facebook 页面获取最新帖子,并仅使用新的 Graph API JavaScript 显示在网站上 - Get most recent post from Facebook page, and display on website using new Graph API JavaScript only
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM