8

I am requesting this page to get the events with the keyword

"conference":https://graph.facebook.com/search?q=conference&type=event

This works fine.

The problem is the pagination returned:

"paging": {
    "previous":"https://graph.facebook.com/search?q=conference&type=event&limit=25&since=2010-12-18T17%3A00%3A00%2B0000",
    "next":"https://graph.facebook.com/search?q=conference&type=event&limit=25&until=2010-11-04T16%3A29%3A59%2B0000"
 }

It seems to have more events with "conference", but requesting these 2 pagination URLS returns no data.

It's weird because it's the same for any requested keyword, and the pagination URLs returned by the Facebook API seems to always returns empty data.

Does anyone know what's the issue?

Thanks

kire
  • 235
  • 1
  • 3
  • 10

3 Answers3

6

I encountered similar confusion with a query against places. The "next" URL behaved exactly as you described it.

I could query location information using a url like this:

https://graph.facebook.com/search?access_token=INSERT_TOKEN&type=place&center=55.8660,-4.2715&distance=150&limit=10

And got back JSON with the first 10 places plus the following fragment which suggests the existence of paging params:

"paging": {
      "next": "https://graph.facebook.com/search?access_token=INSERT_TOKEN&type=place&center=55.8660\u00252C-4.2715&distance=150&limit=10&offset=10"

Hitting that URL doesn't work. But I did figure out a combination of limit and offset params that gave me effective paging.

limit=10 & offset not defined => first 10 results
limit=20 & offset=10 => next 10 results
limit=30 & offset=20 => next 10 results
limit=40 & offset=30 => last 8 results (can stop here because less than 10 back)
limit=50 & offset=40 => confirmation that there are no more results

I realise that I've got "limit" and "offset" rather than the "limit" and "until" params that you get, but, hopefully you could apply the same technique i.e. keep incrementing the limit and inc the date/time to that of your last result?

stephen
  • 1,200
  • 1
  • 13
  • 16
  • 1
    I've been using this method successfully in my app for a few months. Then, some time in April, I started getting customer complaints that the app wasn't working. It turns out that you can no longer rely on getting the full limit number of results you ask for, even though there may be more results than the limit. Have you run into this problem? I'm doing my searches for places. – Tenfour04 May 09 '11 at 02:51
  • I've not been doing anything with the FB API for a while so not sure, sorry. – stephen May 09 '11 at 10:01
  • @TenFour04 please my answer here for a solution on how to get the full limit on every query: http://stackoverflow.com/questions/5023757/how-does-paging-in-facebook-javascript-api-works – Gunnar Karlsson Apr 28 '12 at 01:46
  • Gunnar, thanks for the info. I'm looking into this again in preparation for the February 6 "breaking changes". In my case, the since/until method of paging doesn't apply because I'm using paging search queries for places which returns results in order of proximity, not age. And as far as I can tell, they are only turning off the offsets method for stream search queries. – Tenfour04 Feb 05 '13 at 00:17
1

I think this is a standard practice in Facebook Graph API. I think if your request resulted to a non empty JSON, they will always give you the next paging, even though it might be empty.

I am however not 100% sure, because Facebook Graph API does not seem to be very well documented... (for example they said we can modify this pagination thing but did not explain clearly how to do it).

Enrico Susatyo
  • 19,372
  • 18
  • 95
  • 156
0

Seems facebook has changed it recently. Here's the fix:

For a datetime returned in next and previous as "2011-01-18T08\u00253A42\u00253A35\u00252B0000", replace all occurrences of "\u0025" with "%" and it should work fine.

If you notice the facebook's datetime format, it is 2011-01-18T08:42:35+0000 (date accepted by strtotime C function)

binit
  • 476
  • 1
  • 5
  • 15