brillout
brillout

Reputation: 7444

Search for friend's shared YouTube links

I'm trying to get the list of all YouTube videos shared by friends.

Until now requesting /me/home?q=youtube.com did return all youtube.com links. Apparently the API changed and it seems that it now returns only links that have "youtube.com" in the message body.

Is there a way to retrieve all shared links of a certain domain?

Upvotes: 0

Views: 1223

Answers (1)

林果皞
林果皞

Reputation: 7793

The first thing you have to know is how to get filter key you want,

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

You can refer to https://developers.facebook.com/docs/reference/fql/stream_filter for more detailed.

Example portion of output is:

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

Let's say you get the Link filter_key, then open up https://www.facebook.com/home.php?filter=app_2309869772, the home page only show all the posts which are the "Links" type.

There're two main types of video share from youtube:

The first one is share directly using youtube website's share button, you are require 'nf' as the filter_key. Then you need filter by app_id, which was '87741124305'(you can refer to http://graph.facebook.com/87741124305). You may filter by attribution='Youtube' instead, if you worry the app id may change on the future.

The second is user copy the youtube link and paste into the wall. This kind of post may appear as the 'nf' type. However, it seems most likely youtube link wouldn't appear as 'nf' type. So, you're require filter_key "app_2309869772"(Links) to get these posts. Of course, we want the links which was only the youtube video, so we filter with attachment.caption='www.youtube.com'

So, we combine two filter_key(News Feed and Links) within single fql query, example:

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

(you can edit the link based on your needs, you're not going to put action_links if you're not using this info)

Screenshot tested with https://developers.facebook.com/tools/explorer:

enter image description here

For this example, i using 150 items per page(i using big number because the actual total of posts which was youtube video is not many). You can try to get next page by decrease the created_time, however, that's no guarantee every page have atleast one post.

The link after quote(put you access token at the end) would be:

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=

Cheers

Upvotes: 1

Related Questions