0

我正在尝试获取朋友分享的所有 YouTube 视频的列表。

到目前为止,请求 /me/home?q=youtube.com 确实返回了所有 youtube.com 链接。显然 API 发生了变化,现在它似乎只返回消息正文中包含“youtube.com”的链接。

有没有办法检索某个域的所有共享链接?

4

1 回答 1

1

你必须知道的第一件事是如何获得你想要的过滤键,

SELECT filter_key,name FROM stream_filter WHERE uid = me() 

您可以参考https://developers.facebook.com/docs/reference/fql/stream_filter了解更多详情。

输出的示例部分是:

{
  "data": [
    {
      "filter_key": "nf", 
      "name": "News Feed"
    }, 
    {
      "filter_key": "app_2309869772", 
      "name": "Links"
    }, 

假设您获得了链接 filter_key,然后打开https://www.facebook.com/home.php?filter=app_2309869772,主页仅显示所有“链接”类型的帖子。

youtube 的视频分享主要有两种类型:

第一个是直接使用 youtube 网站的分享按钮分享,您需要 ' nf ' 作为 filter_key。然后您需要按app_id过滤,即“ 87741124305 ”(您可以参考http://graph.facebook.com/87741124305)。如果您担心应用程序 ID 可能会在未来发生变化,您可以改为通过attribution='Youtube'进行过滤。

第二个是用户复制 youtube 链接并粘贴到墙上。这种帖子可能会显示为“nf”类型。但是,似乎 youtube 链接很可能不会显示为“nf”类型。因此,您需要 filter_key " app_2309869772 "(Links) 来获取这些帖子。当然,我们想要的链接只是 youtube 视频,所以我们使用attachment.caption='www.youtube.com'进行过滤

因此,我们在单个 fql 查询中组合了两个 filter_key(News Feed 和 Links),例如:

SELECT action_links,actor_id,app_data,app_id,attachment,attribution,claim_count,comment_info,created_time,description,description_tags,expiration_timestamp,feed_targeting,filter_key,impressions,is_exportable,is_hidden,is_published,likes,message,message_tags,parent_post_id,permalink,place,post_id,privacy,scheduled_publish_time,share_count,source_id,subscribed,tagged_ids,target_id,targeting,timeline_visibility,type,updated_time,via_id,viewer_id,with_location,with_tags,xid FROM stream WHERE post_id IN (SELECT post_id FROM stream WHERE filter_key in(SELECT filter_key FROM stream_filter WHERE uid=me() AND name='Links') AND attachment.caption='www.youtube.com' AND created_time<=now() LIMIT 150) OR post_id IN(SELECT post_id FROM stream WHERE filter_key in(SELECT filter_key FROM stream_filter WHERE uid=me() AND name='News Feed') AND app_id='87741124305' AND created_time<=now() LIMIT 150) ORDER BY created_time DESC

(您可以根据需要编辑链接,如果您不使用此信息,则不会放置action_links )

使用https://developers.facebook.com/tools/explorer测试的屏幕截图:

在此处输入图像描述

对于这个例子,我每页使用 150 个项目(我使用大数字,因为 youtube 视频的实际帖子总数并不多)。您可以尝试通过减少 created_time 来获取下一页,但是,这并不能保证每个页面都至少有一个帖子。

引用后的链接(将您的访问令牌放在末尾)将是:

https://graph.facebook.com/fql?format=json&q=SELECT+action_links%2Cactor_id%2Capp_data%2Capp_id%2Cattachment%2Cattribution%2Cclaim_count%2Ccomment_info%2Ccreated_time%2Cdescription%2Cdescription_tags%2Cexpiration_timestamp%2Cfeed_targeting%2Cfilter_key%2Cimpressions%2Cis_exportable% 2Cis_hidden%2Cis_published%2Clikes%2Cmessage%2Cmessage_tags%2Cparent_post_id%2Cpermalink%2Cplace%2Cpost_id%2Cprivacy%2Cscheduled_publish_time%2Cshare_count%2Csource_id%2Csubscribed%2Ctagged_ids%2Ctarget_id%2Ctargeting%2Ctimeline_visibility%2Ctype%2Cupdated_time%2Cvia_id%2Cviewer_id%2Cwith_location%2Cwith_tags%2Cxid+ FROM+stream+WHERE+post_id+IN+%28SELECT+post_id+FROM+stream+WHERE+filter_key+in%28SELECT+filter_key+FROM+stream_filter+WHERE+uid%3Dme%28%29+AND+name%3D%27Links% 27%29+AND+attachment.caption%3D%27www.youtube。com%27+AND+created_time%3C%3Dnow%28%29+LIMIT+150%29+OR+post_id+IN%28SELECT+post_id+FROM+stream+WHERE+filter_key+in%28SELECT+filter_key+FROM+stream_filter+ WHERE+uid%3Dme%28%29+AND+name%3D%27News+Feed%27%29+AND+app_id%3D%2787741124305%27+AND+created_time%3C%3Dnow%28%29+LIMIT+150% 29+ORDER+BY+created_time+DESC&access_token=

干杯

于 2013-04-09T11:23:41.503 回答