将请求响应与 Facebook 批量请求链接起来
我正在使用 Facebook 的批量请求 发布到多个提要,我需要将正确的响应链接到批次中的每个请求。由于我在文档中没有找到明确的信息,因此返回数组的成员是否以与请求相同的顺序出现?
换句话说,如果我在返回数组的第三个成员中收到错误,这是否肯定意味着该错误涉及我在批次中发送的第三个请求?
我可以使用 id 来表示成功的请求,但错误消息似乎很笼统,并且不会带来任何链接到生成它们的请求的数据(除非我遗漏了某些内容)。
I'm using Facebook's Batch Requests to post to multiple feeds and I need to link the correct response to every request in the batch. Since I found no definitive info on the documentation, do the members of the returned array appear in the same order as the requests?
In other words, if I get an error in the third member of the returned array, does that positively mean that the error refers to the third request I sent in the batch?
I can use the id for succesful requests, but error messages seem general and do not bring any data linked to the request that generated them (unless I'm missing something).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是正确的。
我的策略是在加载批量请求时创建一个跟踪数组。该数组将关联数组的键与我发布批次的数字顺序相关联。当我循环结果时,我使用计数器逐步遍历跟踪数组并提取正确的关联数组索引。然后我用它来使用批处理操作该步骤的结果更新关联数组。
如果批处理支持“名称”参数并且该参数随每个响应一起返回,那就太好了。但这似乎仅在您使用该名称来创建批处理依赖项时才有效:
https://developers.facebook.com/docs/reference/api/batch/
加载批次:
处理批次:
Yes, that's correct.
My strategy is that I create a tracking array as I load up my batch requests. This array correlates the key for my associative array to the numerical order I posted the batches. When I loop over the results, I use a counter to step through the tracking array and pull out the proper associative array index. Then I use that to update the associative array with the results from that step of the batch operation.
It would be nice if batching supported the 'name' parameter and that parameter got returned with each response. But that only appears to work if you're using the name to create batch dependencies:
https://developers.facebook.com/docs/reference/api/batch/
Loading up the batches:
Processing the batches: