Welcome Guest, Not a member yet? Register   Sign In
CI throws 401 on a CURL request
#1

I have created a simple API to check the newest version of software.
If I call this endpoint directly in the browser everything works.
But when I try to get the same contents via curl, a 401 is thrown....
This is the request:
PHP Code:
$handler curl_init($url);
curl_setopt($handlerCURLOPT_RETURNTRANSFERtrue);
curl_setopt($handlerCURLOPT_SSL_VERIFYPEERfalse);
curl_setopt($handlerCURLOPT_HTTPHEADER$headers);
curl_setopt($handlerCURLOPT_POST1);
curl_setopt($handlerCURLOPT_POSTFIELDS$postFields);
$apiOutput curl_exec($handler); 

And this is the (simplified) endpoint:
PHP Code:
    

public function versionInfo()
    {
        $output = ['version' => 2];
        return $this->response->setJSON($output);

    
Reply
#2

READ:

debugbar - HTTP 401 Unauthorized Access Error
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB