Reputation: 2702
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
Upvotes: 3
Views: 6144
Reputation: 7813
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:
Disadvantage:
Kindly inform me if somebody have better query
Cheers
Upvotes: 1
Reputation: 4466
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())
Upvotes: 2
Reputation: 858
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.
Upvotes: 0