8

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.

haynar
  • 5,961
  • 7
  • 33
  • 53

5 Answers5

17

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.

Scott Graph
  • 537
  • 5
  • 11
  • 1
    Where are these params documented? I'm just getting started with the API and I've been looking at this page which doesn't mention them or even the access_token param. https://developers.facebook.com/docs/graph-api/reference/v2.5/user/feed – xr280xr Nov 20 '15 at 23:31
  • 2
    Oh I see. It's "time-based pagination". – xr280xr Nov 20 '15 at 23:42
9

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));

haynar
  • 5,961
  • 7
  • 33
  • 53
  • 2
    this is old, but wondering if you know the resulting URL for those of us not using the php sdk. – spotter Sep 09 '12 at 06:43
1

For me, since and until work when used with the date_format=U parameter, providing values as UNIX timestamps:

me/posts?fields=id,created_time&limit=100&date_format=U&since=1558355000&until=1558356000

Tested in Graph API 2.12 and 3.3

panepeter
  • 3,224
  • 1
  • 29
  • 41
1

There's nothing wrong with your code. Near as I can tell, the Facebook Graph API is broken; the documented paging parameters have no effect when querying connections.

  • yes, paging parameters have no effects, but I've found how to make the limit and other parameters to work :) I'll write in my answer below. – haynar Sep 06 '11 at 12:56
  • unfortunately I can't answer to my own question for 8 hours... so I'll just post it as a comment – haynar Sep 06 '11 at 12:58
0

For me since and until are working when:

me/posts?limit=100&since=2017-01-23T13:11:12&until=2019-08-21T01:11:12&fields=id,created_time

or

me/posts?limit=100&since=2017-01-2313:11:12&until=2019-08-2101:11:12&fields=id,created_time
RobC
  • 22,977
  • 20
  • 73
  • 80
Jeevan
  • 1
  • 1