ashwinks / PHP-LinkedIn-SDK

A PHP wrapper for the LinkedIn API
94 stars 74 forks source link

$authorization_code never gets set #20

Open mikaelz opened 9 years ago

mikaelz commented 9 years ago

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.

minamoto19 commented 8 years ago

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);
}