Facebook comments plugin: sorting comments by default - facebook

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.

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

Facebook FQL query to return all comments against an application [duplicate]

We use the facebook comment plugin to have comments on our site.
To moderate those, we use this tool: https://developers.facebook.com/tools/comments
However, we want to build our own tool to moderate those comments, and integrate it to our existing software.
I can't find a proper way of doing this. the only way I found out now after hours of research is this FQL query:
select post_fbid, fromid, object_id, text, time from comment where object_id in (select comments_fbid from link_stat where url ='URL_HERE')
That doesn't work because we have thousands of different URL's and I cant query each of them every time to see if there are any new comments.
I need a way to get all (new) comments by just enter our app_id, domain or something like that
How can I do this?
I'm considering doing the same thing- grabbing all user posts for my application. I'm assuming it's a similar task.
For given user, I will scroll through feed and home looking for app posts. For you, you'd go:
`home?fields=comments`
`feed?fields=comments`
And check for "type" and "id" to match your application.
This code queries for all comments xids used by your application:
https://graph.facebook.com/fql?q=SELECT fromid, text, id, time, username, xid, object_id FROM comment WHERE xid IN (SELECT xid FROM comments_info WHERE app_id = {0}) ORDER BY time desc&access_token={1}&format=json

Obtain all comments posted to a Facebook social comments page using 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."