问题
Just sharing some information I came across while testing my application.
Facebook Graph API implements rate limiting as described on their documentation page. Today I was trying to retrieve the feed from CNN facebook page and I got the following 500 error:
{"error":{"code":1,"message":"Please reduce the amount of data you're asking for, then retry your request"}}
This is the query I was trying to test:
https://graph.facebook.com/v2.3/5550296508/feed?fields=id,actions,application,caption,created_time,description,from,icon,is_hidden,link,message,message_tags,name,object_id,picture,place,privacy,properties,source,status_type,story,story_tags,to,type,updated_time,with_tags,shares,likes.limit(50),comments.filter(stream).limit(50){attachment,created_time,from,id,like_count,message,message_tags,comments{attachment,created_time,from,id,like_count,message,message_tags}}&access_token=xxxxxxx
回答1:
I tried to set different limit
values to reduce the size, and eventually it worked. By inspecting the response size and playing around with it a bit, I found that the error is thrown when the response reaches (roughly) the 200k threshold.
I tested with Graph API versions 2.3 - 2.4 - 2.5 - 2.6
I found no documentation about this response size limit on the facebook APIs documentation, so it's possible that it will be changed in the future.
Just thought it might be useful to share if you are modelling something using their API.
回答2:
I originally misready the error message Please reduce the amount of data you're asking for, then retry your request
and assumed I was getting rate-limited -- i.e. making too many API calls in a short time period. Thanks Dieghito for your answer, which helped me realize the error is about the response size.
In my case it was fetching /comments
that was exceeding the response size limit. I had the limit set to 1000, which was fine for most posts. But for posts with a lot of lengthy comments, the response size grew too large. I had paging already setup, so simply requesting fewer comments per page (limit: 50 or 100) solved the problem for me. Just posting that here for people whose problem could be related to comments.
来源:https://stackoverflow.com/questions/36730867/facebook-graph-api-response-size-limiting-error-code-1