如何使用LinkedIn Oauth1.0a令牌进行请求? (从JSAPI令牌交换)

时间:2014-12-10 12:09:01

标签: php oauth linkedin

我真的很困惑。我已将LinkedIn JSAPI返回的令牌交换为 3 ,我收到了oauth_tokenoauth_token_secret。我正在使用here中的oauth-php库,并按照LinkedInSO的说明操作。在LinkedIn文档中,步骤4使用pecl oauth库来设置令牌和令牌密钥。 Oauth-php似乎没有类似的方法。我的令牌与此00--xx11xx22-123a-0000-0a0a-12312asda1231asd类似,因此不太像OAuth 2.0令牌。

我试图用我交换的oauth_token调用此方法,但是我一直收到无效的令牌响应。显然我错过了一些步骤。任何帮助都非常感谢。

function linkedin_api_get($exchanged_oauth_token) {
    $url = 'https://api.linkedin.com/v1/people/~';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, "MyLinkedInConnect");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "Authorization: Bearer " . $exchanged_oauth_token,
        "x-li-format: json"
    ));

    $response = curl_exec($ch);
    curl_close($ch);

    return json_decode($response);
}

我猜这个令牌不能用作持票人。但是如何将此令牌交换为承载令牌?或者如何在没有PECL oauth库的情况下正确使用oauth令牌和oauth令牌秘密?

0 个答案:

没有答案
相关问题