简体   繁体   中英

Using FQL or Graph API to retrieve comments from legacy fb:comments widgets

I'm working with a client who has been using the FBML fb:comments widget with the xid parameter to host comments on their blog for quite a while. At some point, they added the migrated=1 parameter.

I am trying to retrieve these comments threads by either the Graph API or FQL, without success. I was able to set up a new page with a modern JS comments widget and retrieve those comments via either method, but I am unclear on how legacy comments are different.

http://graph.facebook.com/comments/?ids=(page_url )

returns an empty set. I can find the page in the link_stat table, which accurately shows the number of comments on the page, but attempting to get the comments with the comment_fbid field value also returns empty sets, with both

http://graph.facebook.com/(comment_fbid)/comments/

http://graph.facebook.com/comments/?ids=(comment_fbid )

as does a FQL query on the comment table with object_id = comment_fbid.

I also tried an FQL query with xid = (page_url), to no avail.

Any pointers on how the legacy comment system interacts with either the Graph API or FQL would be greatly appreciated.

Probably you figured this out by now - however I spend quite some time to figure out a solution for this so others might find this useful:

  • Get an access token: https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=<app_id>&client_secret=<app_secret>
  • Now with the right FQL query the rest is simple: https://graph.facebook.com/fql?q=select%20post_id,%20time,%20text%20from%20comment%20where%20xid=<xid>&access_token=<access_token> ( select time, text from comment where xid=<xid> ).

Obviously you can customize the FQL query to return any parameter from the comments table .

An (actually not so minor) detail: Facebook will return only the comments which belong to your application even without an explicit app_id parameter. So just in case your xids are something 1, 2, 3, you don't need to worry. In fact in my tests Facebook would return no entries if the app_id was specified! (even if it was the same I used to retrieve the access token)

As others have mentioned as well it seems not to be possible to get all comments for an app (regardless of xid or url). The comments_info table which is sometimes referenced in posts seems to be completely empty nowadays.

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