Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LIMIT, SINCE and UNTIL parameters in page feed

I'm trying to get the news feed of page (I'm admin of that page) using the limit, since and until parameters, but it doesn't work, it doesn't work even in graph api explorer tool. I'm requesting the following:

$fb->api("/PAGE_ID/feed?limit=100")

but it always returns me the last 25 posts, the since and until parameters don't work also. What's the wrong in my code?

Thanks in advance.

like image 938
haynar Avatar asked Sep 06 '11 12:09

haynar


People also ask

How does Facebook pagination work?

Time pagination is used to navigate through results data using Unix timestamps which point to specific times in a list of data. To get all a users posts you keep iterating back in time. This method will get you the posts in order, although may want them returned in an order by FaceBooks edge algorithm.


2 Answers

For those not using the PHP SDK and are hitting the relevant Graph API URL directly, simply append

&limit=SOMEPOSITIVEINTEGER

to the end of the URL like so:

https://graph.facebook.com/PAGEGRAPHOBJECTID/posts/&since=2011-07-01&until=2012-08-08&access_token=ACCESSTOKEN&limit=100

Unfortunately, depending on which Graph resource you're hitting, you may get an error if the limit is over a certain threshold and there's no rhyme or reason to this that I can ascertain. For example, getting comments or likes for a post, I've used a limit of 4900 without getting an error. When getting posts from the page feed, that same number gave me an error and now I use a limit of 100 then paginate until my cron sees posts outside the date range.

I imagine though that FB would like for us to use the default limit of 25 and paginate so I'm personally refactoring to accomodate this.

like image 53
Scott Graph Avatar answered Jan 02 '23 09:01

Scott Graph


I've found the right way to use these parameters. I should pass the limit or any other parameters as 3rd parameter when calling api method:

$feed = $this->fb->api("/PAGE_ID/feed", "GET", array('limit' => 2));

like image 40
haynar Avatar answered Jan 02 '23 08:01

haynar