B
B
BadOdealo2020-05-26 17:00:18
PHP
BadOdealo, 2020-05-26 17:00:18

Why is a cURL GET request not being executed?

Good afternoon.
In POSTMAN I made a GET request that receives the token successfully:
5ecd20453d624554251964.png
Generated code for cURL PHP - but it doesn't work:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.selcdn.ru/auth/v1.0",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "X-Auth-User: 122267",
    "X-Auth-Key: 0baN.L:66f"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Please help find the problem!
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Shokhrov, 2020-05-27
@KodyWiremane

I will assume that it CURLOPT_TIMEOUT => 0gives 0 seconds for everything about everything. How about putting something non-zero there like, say, five?

CURLOPT_TIMEOUT - The maximum number of seconds allowed to execute cURL functions.
https://www.php.net/manual/en/function.curl-setopt.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question