0

I sent 50-100 requests to my API at one time with curl, but I got this error :"This object cannot be accessed right now because another API request process is currently accessing it." So I really need to wait for the response of the recently request then execute the next request. How can I do that?

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'site');
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('$header'));
curl_setopt($ch, CURLOPT_POSTFIELDS, '$postfield');

$result = curl_exec($ch);

j08691
  • 204,283
  • 31
  • 260
  • 272
  • That seems like a rate limiting [Stripe](https://stripe.com/docs/rate-limits#handling-limiting-gracefully) does. You can have a look [here on SO](https://stackoverflow.com/questions/42873285/curl-retry-mechanism). `curl` provided some mechanisms to deal with that. – codedge May 03 '20 at 20:48
  • How about add sleep in loop ? How can I do that? Thanks. – Hải Tô Hoàng May 03 '20 at 21:41

0 Answers0