简体   繁体   中英

Facebook Graph API search limit & offset

I want to do a query like this:

search?q=KEY_NAME&type=page&fields=id,name,location&limit=500&offset=0

when I do this the first time the result is about 470 results, now I put offset to 471 and repeat the query

search?q=KEY_NAME&type=page&fields=id,name,location&limit=500&offset=471

and the result is empty.

Why? The key_name is a famous word like "fan" and I don't think that there are only 471 results on fb pages!

What is the problem?

Never use a limit that high, afaik a limit of 100 should be the maximum. Everything else may be buggy. If you use this API call, you get more than 500 with paging:

/search?pretty=0&fields=idmname,location&q=fan&type=page&limit=100

Don´t use "offset", always use the "next" link in the JSON document to get the next batch of results: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.4#paging

The next 100 entries would be available with the following endpoint for me:

/search?pretty=0&fields=idmname,location&q=fan&type=page&limit=100&after=OTkZD

Please refer to this following blog post in which it says https://developers.facebook.com/blog/post/478/

gist of it.

As such, when querying the following tables and connections, use time-based paging instead of “offset” to ensure you are getting back as many results as possible with each call. For these Graph API connections, use the “since” and “until” parameters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM