简体   繁体   中英

Retrieve posts and comments from Facebook wall with Open Graph/FQL

I am finding many difficults while trying to do a rather simple task using facebooks' api (FQL and Open graph).
The task is what the title says getting post-list and relative comments from a user wall i tried via FQL and open graph without results :

Approach 1) open graph
simple me/feed query returns almost what I want but it includes self-references results such as

{
  "id": "1614018744_10200682419255581", 
  "from": {
    "name": "Franco Martinelli", 
    "id": "1614018744"
  }, 
  "story": "\"UNO\" on his own status.", 
  "privacy": {
    "value": ""
  }, 
  "type": "status", 
  "created_time": "2013-06-16T13:49:58+0000", 
  "updated_time": "2013-06-16T13:49:58+0000"
},

and i cant seem to find what to filter to exclude those records or if i am supposed to filter on my end

Approach 2) With this query in FQL

{"q1":"SELECT post_id, actor_id,target_id, message FROM stream 
WHERE source_id=me() 
AND type in (46,56,80,128,247) AND created_time < 1371254400 LIMIT 250",
"q2":"SELECT text from comment where post_id IN (SELECT post_id FROM #q1)"}

i get my own posts but not post made by others and also the limit clause works in mysterious way from what i have read around.
I have used twitter api's without a single problem,i cant believe i have to go through all this mess for a simple request.

Here are the two queries. You need to include type = 'newsfeed' then that would bring up posts made by your friends,just like your news feed on facebook.com

getpost: ("SELECT actor_id, created_time, likes, post_id, message FROM stream WHERE filter_key IN (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0"),
users: ("SELECT id, name, url, pic FROM profile WHERE id IN (SELECT actor_id FROM #getpost)")

http://fbdevwiki.com/wiki/FQL:stream

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM