为什么 Facebook 批量 API 请求有时会返回 null?
我在我的应用程序中经常使用 Facebook 的批量请求。在大多数情况下,它工作得很好,但让我困惑的一件事是为什么他们的 API 有时会返回 null?如果我得到这个“空”响应,我可以稍后再试一次,它就会起作用。
下面是一个示例:
URL:
https://graph.facebook.com/?access_token={access_token}
请求正文(编码之前):
batch=[{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"},{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"},{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"},{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"}]
这是 Facebook 有时返回的内容:
[null,null,null,null]
如果我提出相同的请求一秒钟后,我得到了正确的回应:
[{"code":200,"headers":[...headers here...],"body":{...body here...},{"code":200,"headers":[...headers here...],"body":{...body here...},{"code":200,"headers":[...headers here...],"body":{},{"code":200,"headers":[...headers here...],"body":{...body here...}}]
行为并不总是一致的。大多数时候我可以再试一次并得到正确的回应。有时候我需要尝试2到3次。这个问题每天都会发生几十次,从我记事起它就一直在发生。我在 Facebook 上检查了我的应用程序诊断,发现我的应用程序没有任何限制,没有 API 限制,Facebook 甚至没有在其“API 错误”报告下列出这些内容。知道为什么会发生这种情况吗?
I use Facebook's batch request quite a bit in my app. For the most part, it works really well, but one thing that confuses me is why does their API sometimes return nulls? If I get this "nulls" response, I can just try again moments later and it will work.
Here's an example:
URL:
https://graph.facebook.com/?access_token={access_token}
Request Body (prior to encoding):
batch=[{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"},{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"},{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"},{"method":"GET","relative_url":"{page_id}?return_ssl_resources=1"}]
Here's what Facebook sometimes returns:
[null,null,null,null]
If I make the same request a second later, I get the proper response:
[{"code":200,"headers":[...headers here...],"body":{...body here...},{"code":200,"headers":[...headers here...],"body":{...body here...},{"code":200,"headers":[...headers here...],"body":{},{"code":200,"headers":[...headers here...],"body":{...body here...}}]
The behavior is not always consistent. Most of the time I can try again and get a proper response. Occasionally I need to try 2 to 3 times. This problem happens dozens of times a day and it's been going on as long as I can remember. I checked my App diagnostics on Facebook and my App doesn't have any restrictions, there's no API throttling, and Facebook doesn't even list these under their "API Errors" report. Any idea why this happens?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来这个问题已经自行纠正了。我已经好几天没有看到这个错误出现了。
错误报告在这里:
http://developers.facebook.com/bugs/295201867209494?browse=search_4f42b29071ebc7f92807017
It seems that this problem has corrected itself. I haven't seen this error show up for a few days now.
Bug report here:
http://developers.facebook.com/bugs/295201867209494?browse=search_4f42b29071ebc7f92807017