Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top