I'm building a Facebook application and I want it to be able to read all the user's statuses from the past year. When I make the API call, I can only retrieve the first 100 statuses no matter what I set the limit to.
Here's the URL I'm using to make the call: https://graph.facebook.com/me/statuses?limit=100&access_token=...
When I set the limit lower, it shows fewer statuses (proving that the limit argument works). When I set the limit higher, it only gives me the first 100. When I use 'since', it still only gives me 100.
When I use the 'next' url it gives me, I see no data past the first 100 statuses.
I know it's possible to get much more than that because of applications such as My Year In Status
It does work. You must use both the limit
and offset
query parameters. The limit
parameter sets the batch size. The offset
parameter sets the position in the user's all-time status collection. Without specifying the offset
parameter, Facebook defaults it to zero, which is why you keep seeing the same dataset.
For the 1st batch of 100 statuses, set limit
to 100
and offset
to 0
.
For the 2nd batch of 100 statuses, set limit
to 100
and offset
to 100
.
For the 3rd batch of 100 statuses, set limit
to 100
and offset
to 200
.
For the 4th batch of 100 statuses, set limit
to 100
and offset
to 300
.
And so on...
Keep iterating until you get an empty dataset:
{
"data": []
}
I've verified using the Graph API explorer that the pagination is not working as you have described. Log it as a bug with Facebook at: https://developers.facebook.com/bugs and post the bug # here.
EDIT
Per the bug closure, the 100 limit is By Design and you won't get more than that, meaning that Facebook has made a conscious business decision to limit the amount of data it has to store, process, and serve from the Graph API. It costs money to do so and since the API is free to use, I can't argue with them. However, if I was paying for it, then hell yes I kick and scream all the way down the road.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With