@kawashita Sounds like you need to look into Guzzle. You can use this to call the API from PHP and hand the response directly to the code creating the Excel file.
Right method to request a queue API
Ok so this might seems easy for some and complicated for others, I belong to the group who think it is complicated So if someone please can give me a solution
I am going to deal with an API, I am the client, I will do a request get a Json response of a list of info and format this Json object into an excel file then save it in some folder with a proper logic.
I could do all this but here is the tricky part:
the API is a Queue, for each time I request it a new object is sent in a response, once I get that response, the object disappears from the queue and lead to the next one until the queue gets empty and I would receive an empty body or some flag telling me "0 remaining".
How would I be able to continue to perform requests and stop right at when the queue is empty then get back to it when there is a new object waiting to be read?
This sounds like a strange scenario.. but I think the way to approach this is to have a cron task that runs every minute, every 5 minutes, whatever frequency.. and it should first check if queue items are being processed by looking at a flag set in the DB or similar. If no items are being processed, initiate your api call to fetch an item from the queue -- this is where you'll set that items are being processed.. After receiving an item and processing it, hit the api again.. repeat until you get your empty state, at which point you then toggle the processing flag off again. Next time the cron job runs it'll see processing is not occurring, flip the flag, check the api, and either process items or toggle the flag back off.
Please or to participate in this conversation.