getting all post comments under limit using facebook fql query

I have been trying to use Fql query to show all comments for a post.at first i show 2 posts then when 'show more comments' clicked i show next 50 comments,this way it continues.when 'show more comments' i execute following by ajax call to graph api with -

SELECT text,post_id  FROM comment  WHERE post_id=post_id limit 50

but say when i first click 'show more comments' it shows 52 comments,then when i click again it shows around 102 comments.but for next clicks 152 comments not shown.its stays in around 102 comments.

my target -

1st click to 'show more comments' = show 52 comments starting from first comments(limit value = 52 i specify in query )

2nd click = show 102 comments starting from first comments(limit value=102)

3rd click = show 152 comments starting from first comments(limit value=152) ......continues

so i am not able to achieve this.I really tried many ways using offset too.lots of problems.Are there facebook bugs? kindly help asap.

Answers


You should try out cursor pagination, it's recommended as explained at https://developers.facebook.com/docs/reference/api/pagination/

Returned results under cursor paging more consistently match the limit requested, even after hiding any records for which you do not have permissions to view (eg. if you request 10 records, but do not have permissions to see 3 of those records, 3 additional records will be pulled transparently, so that a full 10 records are pulled).

Example with post_id_cursor:

SELECT text, post_id, post_id_cursor FROM comment WHERE post_id='22707976849_10151395520781850' ORDER BY time DESC limit 50

You get the post_id_cursor of the last comment, then navigate next page with >post_id_cursor symbol

SELECT text, post_id, post_id_cursor FROM comment WHERE post_id='22707976849_10151395520781850' AND  post_id_cursor>'Mjg3NA==' ORDER BY time DESC limit 50

Example with object_id_cursor is same:

SELECT text, post_id, object_id_cursor FROM comment WHERE object_id='10151395520696850' ORDER BY time DESC limit 50

SELECT text, post_id, time, object_id_cursor FROM comment WHERE object_id='10151395520696850' AND object_id_cursor>'Mjg3NA==' ORDER BY time DESC limit 50

Update:

Make sure you enabled "July 2013 Breaking Changes:" field at your app advanced settings, https://developers.facebook.com/apps/YOUR_APP_ID/advanced. More info at https://developers.facebook.com/roadmap

Example of get feed for certain user:

https://developers.facebook.com/tools/explorer?fql=%7B%22query1%22%3A%22SELECT%20post_id%2C%20actor_id%2C%20created_time%2C%20message%20FROM%20stream%20WHERE%20source_id%3D611693239%20AND%20created_time%3C%3Dnow()%20LIMIT%2050%20%22%2C%22query2%22%3A%22SELECT%20post_id%2C%20id%2C%20fromid%2C%20time%2C%20text%2C%20user_likes%2C%20likes%20FROM%20comment%20WHERE%20post_id%20IN%20(SELECT%20post_id%20FROM%20%23query1)%20LIMIT%205%20%22%2C%22query3%22%3A%22SELECT%20id%2C%20name%2C%20pic_square%20FROM%20profile%20WHERE%20id%20IN%20(SELECT%20actor_id%20FROM%20%23query1)%20or%20id%20IN%20(SELECT%20fromid%20FROM%20%23query2)%22%7D%0A


Need Your Help

SharePoint Claims-Authentication, Cookies, C#, and Excel-DLL/tld

c# excel sharepoint dll claims-based-identity

The basic concept of the project is it accesses SharePoint, verifies a certain file exists, verifies the file is NOT locked by another user, and then, if those two conditions are met, excel opens the

c# what wpf control to use for showing text file

c# wpf-controls

Whats the best control to use in wpf applicaion for loading big text files into? And its not just simple as that, i need to be able to hightlight/change background/color of some lines. I was thinki...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.