![]() |
Error in using CURLRequest Class in case of GET type request - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Error in using CURLRequest Class in case of GET type request (/showthread.php?tid=83788) |
Error in using CURLRequest Class in case of GET type request - datamweb - 10-12-2022 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: { So I expect to see the same response as above when I use: PHP Code: 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 can you help Where is the problem? RE: Error in using CURLRequest Class in case of GET type request - InsiteFX - 10-12-2022 Thats a GitHub error not CodeIgniter, CodeIgniter is relaying the error. RE: Error in using CURLRequest Class in case of GET type request - datamweb - 10-12-2022 @InsiteFX Thanks for the reply. My question is exactly the same, why don't I have such an error in the Terminal or Postman? It is the same with Google(https://www.googleapis.com/oauth2/v3/userinfo). And what is the solution? RE: Error in using CURLRequest Class in case of GET type request - michalsn - 10-12-2022 I'm not sure what's going on with SSL, but you should get some information from the debug option (in your example, it's set incorrect). Try something like this: PHP Code: $response = $client->request('GET', 'https://api.github.com/user', [ I would not assume to always get JSON in response. Instead, check the content type and status code. RE: Error in using CURLRequest Class in case of GET type request - kenjis - 10-12-2022 Code: $ curl https://api.github.com/user -i Quote:By default, CURLRequest will fail if the HTTP code returned is greater than or equal to 400. You can set http_errors to false to return the content instead: PHP Code: $client = \Config\Services::curlrequest(); I see Code: 401 If I removed Usesr-Agent, I got this: Quote:Request forbidden by administrative rules. Please make sure your request has a User-Agent header (https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required). Check https://developer.github.com for other possible causes. It seems I cannot reproduce the OpenSSL error: Code: OpenSSL SSL_connect: Connection was reset in connection to api.github.com:443 RE: Error in using CURLRequest Class in case of GET type request - datamweb - 10-12-2022 @michalsn And @kenjis .Thank you , by correcting the said items, the problem was solved. Also, error "OpenSSL SSL_connect: Connection was reset in connection to api.github.com:443" is not related to your CI or code, if someone from IRAN has this problem, message me directly. |