等待图 api / 批处理 api 的结果
我怎么能不等待API调用的响应呢?
我有一大批 API 调用(一个依赖于另一个),但应用程序不需要结果。只需说“Facebook 这样做”,无需等待回复。
我怎么能不等待回复呢?
How can I not wait for response from API call?
I have a big batch of API calls (one depends on other) but application does not need the results. Just say "Facebook do this" and do not wait for response.
How can I not wait for a response?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不久前我参与了一个项目,我们在该项目中实现了类似的排队功能。 (该应用程序发布到大约 150 个页面的墙上以及一些其他数据收集。
我们的解决方案是这样的:
我们有一个填充有作业的队列表。这些由参数、令牌和特定的 Facebook API 调用组成。该表还有一个状态。列被设置为计划/成功/失败,一个响应列和几个日期时间列,计划和发送
寻找计划作业的脚本,然后运行 API 调用并收集由 cron 作业以任意时间间隔运行的响应。
应用程序本身可以查看队列表并生成有关已运行的作业及其响应的报告,以及即将到来的预定工作。
I was involved in a project a while back where we implemented queuing for something similar to this. (The application was posting to the walls of around 150 pages as well as some other data collection.
Our solution was this:
We had a Queue table that was populated with Jobs. These were made up of the parameters, token and the particular Facebook API call. The table also had a status column that was either set to scheduled/success/fail, a response column and a couple of datetime columns, scheduled & sent.
A script that looked for scheduled jobs, then ran the API calls and collected the response was run by a cron job at an arbitrary interval.
The application itself could look at the Queue table and produce a report of what jobs had been run and their responses, as well as the upcoming scheduled jobs.
我相信您正在寻找一种执行异步 php 调用的方法。您最终可能会自己执行一些查询,因为我认为 PHP FB SDK 不支持此类查询。
我相信curl_multi(仅限php5)是您寻找的解决方案:
您可能还会发现此 QA 很有帮助:
I believe you are looking for a way to do a async php calls. You may end up with doing some queries by yourself, as I don't think PHP FB SDK support such queries.
I believe curl_multi (php5 only) is a solution you look for:
You may also find this QA helpful: