Obtain all comments posted to a Facebook social comments page using FQL - facebook-fql

Is there a way to use FQL to obtain the XID of all comments posted on any page associated with a particular Facebook application ID?
The docs listed for FQL on the comments_info table at this address seem to suggest that it is possible:
http://developers.facebook.com/docs/reference/fql/comments_info/
If I attempt the following query however, it returns no results.
SELECT xid FROM comments_info WHERE app_id = {MY_APP_ID}
I want to use this to find the most popular pages without individually checking each URL to determine which one has the most posts.

If you are trying to get comments from the Comments plugin, try the comment FQL table instead. Legacy fb:comments were auto-migrated to the latest version a while ago, effectively rendering *comments_info* obsolete.
From the *comments_info* docs page:
"Note: This table contains a mapping of app_id to XIDs used by legacy fb:comments. It does not contain a map for the current comments plugin, which does not use XIDs."

Related

How to limit Facebook Graph API to only posts (not comments or likes) by user without using FQL?

I am trying to query the FB graph API for all of my posts. I would like the result set to only feature items that I've posted on my timeline. Not other users, and not my likes or comments.
The documentation is extremely confusing and most of the knowledge I've gained is through trial and error. To date, the only proposed solutions to this I've found online require the use of FQL (such as in this similar question: Facebook graph api- how to get user feed,with out posts about likes and comment by the user?) however the FB documentation states that FQL is deprecated and will not be supported in the future so I would like to avoid it. Additionally this is currently structured as a url request and if at all possible, I would like to keep it so.
To date, I've tried:
/[userid]?fields=posts.limit(100).fields( picture, link, created_time, from, message, description, object_id )
which will get me all of my posts with the data fields I require, but it also includes "Likes" and when I "Comment" anywhere - which I don't want.
/[userid]?fields=feed.limit(100).fields( picture, link, created_time, from, message, description, object_id )
which returns only posts - but also includes posts made by others on my timeline (and I don't want those either).
It seems unclear to me if there is any more robust way to work with these different feed types as documented:
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed/
Can anyone tell if there is a way to either limit the "feed" edge to only my posts (not including others posting to my timeline) or filter the "posts" edge to remove the "likes" and "comments"?
Instaead of /feed, you can use /posts.
More info here:
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed
It's not possible as far as I know to generally apply filters to the Graph API calls, except very little exceptions.
/user/feed is an example (https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed/#read), where you can specify either with=location or filter={stream_filter}.
{stream_filter} in this case is a result of the filter_key field of the following FQL query:
select filter_key, name from stream_filter where uid=me()
Maybe you can try
GET /me/feed?filter=app_2915120374
which should give you the status updates.

Facebook Api getting feeds and comments

I'm trying to get the feeds on a public wall and the associated comments.
So every X minutes I'm doing a query in order to get what's new (feeds and comments).
I need the feeds (the new feeds since myDate) and comments (comments posted on the new feeds and comments posted on older feeds).
So if someone posted a comment on a older feed I want to get it.
I tryied to do this using FQL and Graph API but I don't manage to find the best solution.
With FQL there are some problems (bugs) with LIMIT and OFFSET and does not work very well.
With the Graph API I don't have so much power.
So this is what I've tryied:
https://graph.facebook.com/PAGE_ID/feed?access_token=MY_ACCES_TOKEN0&limit=500&since=1350033469&until=now&updated_time>1350033469
This gives me the newest post, so no problem because for each one I'm doing a new query in order to get the comments for each feed:
https://graph.facebook.com/PAGE_ID/comment?access_token=MY_ACCES_TOKEN0&limit=500&since=1350033469&until=now&updated_time>1350033469
The problem is that if a comment is posted on a older post, I don't receive it.
Using FQL I cannot filter only the newest posts (based on my since date) and the posts with new comments.
https://api.facebook.com/method/fql.query?query=SELECT post_id, text, fromid FROM comment WHERE post_id IN (SELECT post_id FROM stream where source_id=PAGE_ID and comments.created_date>1350033469)&access_token=MY_ACCES_TOKEN
Using Graph API I have a good pagination (using next and previous links inside the response) but with FQL I did't find any solution.
So anyone have some idea ?
Thanks.
C.C.
First, the FQL is deprecating, so you need to use only the Graph API.
The solution that I came with, is that when you already have a post, you need to recheck the post with its unique ID, and that request gives you two times, created_time and updated_time, so you need to check if your updated_time changed.
The pagination given in the Graph API is for only posts, so when posts have new comments, they won't come first in the list, you need to find them yourself.
-- UPDATE --
Use batch_requests to achieve this, so you can make more requests at a time.

Retrieve ALL Facebook Comments for website/App ID Using Graph API (i.e. get latest comments)

I'm trying to create a feed of latest comments for a website. I don't have any problem getting comments on a per post basis but I don't seem to be able to find any way to get all, or at least the last 10 comments for the entire website.
Obviously I'd like to do this in the simplest way possible and I figured this would be via the Graph API.
Any suggestions appreciated.
Thanks
I think you might have to enter all the URLs, but it can be done via FQL using the comments and link_stat table.
SELECT xid, text, username, time
FROM comment
WHERE
object_id IN
(SELECT comments_fbid FROM link_stat WHERE url IN (All_your_URLs))
Can you try the above and see if it works ?
Reference - Comments & Link_Stat

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.

Facebook comments plugin: sorting comments by default

By default the comments are shown by "social ranking".
Is it possible to set the default value to "reverse chronological"?
The official docs for social plugins does not mention this option...
If you are using the social plugin given by FB, then i think there is no such option available..
what do u mean by Social ranking?
If you are ready to use FQL then you can try my below suggestion.
Normally all FB data are rendered based on timestamps , so if u want to get the latest comments for a specific page, you can use the FQL query to get desired results..
Sample query
http://www.facebook.com/restserver.php?format=json&pretty=1&method=fql.query&
query=select post_fbid, fromid, object_id, text, time from comment where
object_id in (select comments_fbid from link_stat where
url ="http://developers.facebook.com/docs/reference/fql/comment/")
order by time desc
I answered here too: Setting Facebook comments web plugin
It just works if you add the attribute
data-order-by="reverse_time"
to the div provided in the html5 version provided by Facebook.
(sorry for the duplicate answer. I came across here googling, that's why I think is usefull to post it here too)
Sorry for exact duplicate, but it is possible to set the default sorting order to reverse chronological. See my answer here.