Facebook graph api- how to get user feed,with out posts about likes and comment by the user?

烈酒焚心 提交于 2019-12-18 04:23:22

问题


i am developing a fb app,in which i want to give the users time line,but i need to exclude stories like "User likes a photo","coments on friends's photo".how i filter and exclude these types of stories


回答1:


You can filter these Posts by looking for the presence of the story or story_tags key as these is not present in the Posts made by the User.

Quoting from the documentation the description of story key

Text of stories not intentionally generated by users, such as those generated when two users become friends; you must have the "Include recent activity stories" migration enabled in your app to retrieve these stories

Or you may try FQL's stream like this

select message from stream where source_id=me() and type in (46,56,80,56,128,247)
and filter_key in (select filter_key from stream_filter where uid=me())

which might help you to reduce the Posts to one that you desire.

Update

You might not require to reduce the result using type field as verified by 林果皞 , so the query reduces to

select message from stream where source_id=me() AND filter_key in
(select filter_key from stream_filter where uid=me())



回答2:


Use fql, the "type" field is "null" if the description is something like "A followed B", "A likes Intel.", "A commented on his own link."...etc:

SELECT created_time,description,likes,message,post_id FROM stream WHERE source_id=me() AND type!="" AND created_time<=now() LIMIT 50 

Update: I found my query doesn't exclude post on page story, Anvesh Saxena's answer is correct than mine.

select message from stream where source_id=me() AND filter_key in (select filter_key from stream_filter where uid=me())

Update Wed may 15 2013: Seem we have trouble because different filter_key may have hold the same post_id. For example, some link may appear both at "nf" filter_key and Links filter_key "app_2309869772"

Update:i do some research and finally come out this query(Replace 2 "me()" to other user_id is works too):

SELECT viewer_id, app_id, target_id, post_id, created_time, message, type, permalink FROM stream WHERE source_id=me() AND created_time<=now() AND ((type IN(46,80,128,237,247)) OR (type="" AND target_id=me())) LIMIT 150

This FQL API query compare with web browser(I tested with clicked "All stories" on my wall):

Advantage:

  • All duplicated feeds which was created within short period of time would included. Web browser version may exclude this duplicated feeds.

Disadvantage:

  • "tagged by somebody" wouldn't included(It's make sense because the source id is not me(), and no point to query all friends and filter by me() IN(tagged_ids) because of performance concern)
  • "Update cover photo" and "Update profile photo" feed wouldn't included.
  • I found there's case user's post via mobile doesn't return from stream table even specific the post_id, it's nothing we can do.
  • "(type="" AND target_id=me())" doesn't works when your friend share photo and links on your timeline. Status shared by friend is works.

Kindly inform me if somebody have better query

Cheers




回答3:


All the json data you get from Graph api when requesting users feed, has an element 'type' which can be e.g. Link, comment, status.... Chose the ones you need.



来源:https://stackoverflow.com/questions/16481191/facebook-graph-api-how-to-get-user-feed-with-out-posts-about-likes-and-comment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!