private function getAccessToken($code)
    {

        $data        = [
            "client_id"     => $this->clientId,
            "client_secret" => $this->clientSecret,
            "code"          => $code
        ];
        $data_string = json_encode($data);

        //This needs to be replaced with Guzzle or something async
        $ch = curl_init('https://github.com/login/oauth/access_token');
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt(
            $ch,
            CURLOPT_HTTPHEADER,
            [
                'Content-Type: application/json',
                'Content-Length: ' . strlen($data_string)
            ]
        );

        $result = curl_exec($ch);
        parse_str($result, $resultArray);

        if (isset($resultArray['access_token'])) {
            return $resultArray['access_token'];
        } else {
            return false;
        }
    }
private function getAccessToken($code)
    {

        $data        = [
            "client_id"     => $this->clientId,
            "client_secret" => $this->clientSecret,
            "code"          => $code
        ];
        $data_string = json_encode($data);

        //This needs to be replaced with Guzzle or something async
        $ch = curl_init('https://github.com/login/oauth/access_token');
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt(
            $ch,
            CURLOPT_HTTPHEADER,
            [
                'Content-Type: application/json',
                'Content-Length: ' . strlen($data_string)
            ]
        );

        $result = curl_exec($ch);
        parse_str($result, $resultArray);

        if (isset($resultArray['access_token'])) {
            return $resultArray['access_token'];
        } else {
            return false;
        }
    }
private function getAccessToken ( $ code ) { $ data = [ "client_id" => $ this -> clientId , "client_secret" => $ this -> clientSecret , "code" => $ code ] ; $ data_string = json_encode ( $ data ) ; //This needs to be replaced with Guzzle or something async $ ch = curl_init ( 'https://github.com/login/oauth/access_token' ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , "POST" ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ data_string ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , [ 'Content-Type: application/json' , 'Content-Length: ' . strlen ( $ data_string ) ] ) ; $ result = curl_exec ( $ ch ) ; parse_str ( $ result , $ resultArray ) ; if ( isset ( $ resultArray [ 'access_token' ] ) ) { return $ resultArray [ 'access_token' ] ; } else { return false ; } }
Get access token from code

@param string $code
@return string|boolean
Get access token from code