Welcome Guest, Not a member yet? Register   Sign In
Error in using CURLRequest Class in case of GET type request
#1

(This post was last modified: 10-12-2022, 01:12 AM by datamweb.)

Hi guys, I'm use CURLRequest Class

I used to have no problem using it, but now I have a problem.
The answer to command

Code:
curl https://api.github.com/user

is as follows:

Code:
{
  "message": "Requires authentication",
  "documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user"
}

So I expect to see the same response as above when I use:

PHP Code:
           
$client 
= \Config\Services::curlrequest();
                $response $client->request('GET''https://api.github.com/user', [
                    ['debug' => true],
                ]);

            return json_decode($response->getBody()); 

But I have an error, see the content of file log:

Code:
CRITICAL - 2022-10-12 02:03:36 --> 35 : OpenSSL SSL_connect: Connection was reset in connection to api.github.com:443
in SYSTEMPATH\HTTP\CURLRequest.php on line 655.
1 SYSTEMPATH\HTTP\CURLRequest.php(655): CodeIgniter\HTTP\Exceptions\HTTPException::forCurlError('35', 'OpenSSL SSL_connect: Connection was reset in connection to api.github.com:443 ')
2 SYSTEMPATH\HTTP\CURLRequest.php(363): CodeIgniter\HTTP\CURLRequest->sendRequest([...])
3 SYSTEMPATH\HTTP\CURLRequest.php(136): CodeIgniter\HTTP\CURLRequest->send('GET', 'https://api.github.com/user')
4 APPPATH\Controllers\Home.php(36): CodeIgniter\HTTP\CURLRequest->request('GET', 'https://api.github.com/user', [...])
5 SYSTEMPATH\CodeIgniter.php(902): App\Controllers\Home->index()
6 SYSTEMPATH\CodeIgniter.php(457): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Home))
7 SYSTEMPATH\CodeIgniter.php(340): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false)
8 FCPATH\index.php(67): CodeIgniter\CodeIgniter->run()
9 SYSTEMPATH\Commands\Server\rewrite.php(46): require_once('FCPATH\\index.php')

can you help Where is the problem?
Reply


Messages In This Thread
Error in using CURLRequest Class in case of GET type request - by datamweb - 10-12-2022, 12:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB