1

I'm trying to use Guzzle to make multiple requests, but when I try to get the response I keep getting a cURL 77 error. I'm connecting to Zoom API using JWT. I have an array of 700 items, so for each item, I'm trying to create a request using getAsync passing the jwt token.

My code is like this:

foreach ($agrupado as $registro) {
$requestArr[$registro['id']] = $cliente->getAsync('https://api.zoom.us/v2/webinars/'.$id.'/registrants/'.$registro['id'], [
                'headers' => [
                    'Authorization' => 'Bearer '.$jwt
                ]]);
}
$respostas = \GuzzleHttp\Promise\unwrap($requestArr);
var_dump($respostas);

If I do the same request, using the get method, and same token, it works. I get the response, with no problem. It's very weird.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
churros
  • 419
  • 1
  • 8
  • 20
  • Tried turning off [certificate verification](http://docs.guzzlephp.org/en/stable/request-options.html#verify)? `new Client(['verify' => false]);`? If that works maybe your CA bundle is out of date. – ficuscr Jul 16 '20 at 20:43
  • 1
    Does this answer your question? [How do I deal with certificates using cURL while trying to access an HTTPS url?](https://stackoverflow.com/questions/3160909/how-do-i-deal-with-certificates-using-curl-while-trying-to-access-an-https-url) – ficuscr Jul 16 '20 at 20:44
  • It's very weird this certificate thing. I never used certificates to consume Zoom's API. In fact, I have the same script, with the same logic, working, using pure PHP's CURL. My idea now using Guzzle is to make the script more simple and fast. So, I don't get it. Do I need to use certificate for this getAsync method? – churros Jul 17 '20 at 00:30
  • See the question I linked. If you are using HTTPS you are using private/public keys, certificates, and if your CA bundle on the server is out of date you can't make a secure connection. If skipping the verification things work then address the root issue. – ficuscr Jul 17 '20 at 19:01
  • Yeah, I saw that. But I am able to make the request. The problem is when I'm using Guzzle and multiple requests. If I just do one single resquest to that endpoint, it works. So, it's a message about certificate, but the problem seems to be other. If was a certificate problem, I wouldn't be able to make a single request, right? – churros Jul 18 '20 at 22:39
  • Need to see the full error message and ideally you should get verbose output and see both raw request and response with headers. Have you looked at the APIs rate limits? – ficuscr Jul 20 '20 at 04:54

1 Answers1

0

I found this tutorial and now I'm able to make multiple requests using Guzzle to Zoom's API.

I think that the problem was that I was making a lot of request, and the API at some point was rejecting the calls. I know that because I tested it with a few request, like 5, or 10. And it was fine. When I did 30 request, I get the certificate error.

So, I implemented the example on this tutorial (Concurrency in Promise) using Guzzle's promises and the EachPromise class. I keep a low number of concurrency and use the method wait at the end of the script. Now everything is working.

churros
  • 419
  • 1
  • 8
  • 20