PHP-LinkedIn-SDK icon indicating copy to clipboard operation
PHP-LinkedIn-SDK copied to clipboard

$authorization_code never gets set

Open mikaelz opened this issue 9 years ago • 1 comments

At https://github.com/ashwinks/PHP-LinkedIn-SDK/blob/master/LinkedIn/LinkedIn.php#L241 the method call has no param and so at https://github.com/ashwinks/PHP-LinkedIn-SDK/blob/master/LinkedIn/LinkedIn.php#L95 the $authorization_code never gets a value and so it can't function.

mikaelz avatar Aug 14 '15 09:08 mikaelz

Yes, you are right I have no idea how this code could work at any point. so remove https://github.com/ashwinks/PHP-LinkedIn-SDK/blob/master/LinkedIn/LinkedIn.php#L240 as its not needed. Remove everything after trim($endpoint, '/\\') at https://github.com/ashwinks/PHP-LinkedIn-SDK/blob/master/LinkedIn/LinkedIn.php#L241 Finally on https://github.com/ashwinks/PHP-LinkedIn-SDK/blob/master/LinkedIn/LinkedIn.php#L243 replace $this->getAccessToken() with $this->_access_token.

For me fetch function looks like this and works:

public function fetch($endpoint, array $payload = array(), $method = 'GET', array $headers = array(), array $curl_options = array()) {
    $endpoint = self::API_BASE . '/' . trim($endpoint, '/\\');
    $headers[] = 'x-li-format: json';
    $headers[] = 'Authorization: Bearer ' . $this->_access_token;
    return $this->_makeRequest($endpoint, $payload, $method, $headers, $curl_options);
}

minamoto19 avatar Mar 05 '16 17:03 minamoto19