Facebook 图 API 响应大小限制(错误代码 1)

Facebook graph API response size limiting (error code 1)

只是分享我在测试我的应用程序时遇到的一些信息。

Facebook Graph API 按照其 documentation page 中的描述实施速率限制。今天我试图从 CNN facebook 页面检索提要,但我收到以下 500 错误:

{"error":{"code":1,"message":"Please reduce the amount of data you're asking for, then retry your request"}}

这是我试图测试的查询:

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

我尝试设置不同的 limit 值来减小尺寸,最终成功了。通过检查响应大小并稍微尝试一下,我发现当响应(大致)达到 200k 阈值时会抛出错误。

我测试了 Graph API 版本 2.3 - 2.4 - 2.5 - 2.6

我在 facebook API 的文档中没有找到关于此响应大小限制的文档,因此将来可能会更改它。

只是觉得如果您正在使用他们的东西建模,分享可能会有用 API。

我最初错误地准备了错误消息 Please reduce the amount of data you're asking for, then retry your request,并假设我得到了 rate-limited -- 即在短时间内进行了太多的 API 调用。感谢 Dieghito 的回答,这帮助我意识到错误与响应大小有关。

在我的例子中,它正在获取超过响应大小限制的 /comments。我将限制设置为 1000,这对大多数帖子来说都很好。但是对于有很多冗长评论的帖子,回复量变得太大了。我已经设置了分页,所以只需要求每页更少的评论(限制:50 或 100)就解决了我的问题。只是为了那些问题可能与评论有关的人张贴在这里。