3

我目前正在尝试在我的网站上安装 LinkedIn 的登录按钮。正如开发人员部分所示,我正在尝试逐步进行。在我编写了获取请求令牌的代码并使用 print_r 检查它之后。

define("my consumer key");
define("my consumer secret");

$oauth = new OAuth(my consumer key, my consumer secret);

//The first item of business is getting a request token
$request_token_response = $oauth->getRequestToken('https://api.linkedin.com/uas/oauth/requestToken');

if($request_token_response === FALSE) {
        throw new Exception("Failed fetching request token, response was:"
        . $oauth->getLastResponse());
} else {
        $request_token = $request_token_response;
}

print "Request Token:\n";
printf("    - oauth_token        = %s\n", $request_token['oauth_token']);
printf("    - oauth_token_secret = %s\n", $request_token['oauth_token_secret']);
print "\n";

我收到“致命错误:未捕获的异常 'OAuthException'...无法使用已知 CA 证书对对等证书进行身份验证”。为错误调用的行如下

$request_token_response = $oauth->getRequestToken('https://api.linkedin.com/uas/oauth/requestToken');

我不明白该错误试图告诉我什么,以便我可以解决问题。我将不胜感激并提供提示或指导,以帮助我更好地了解此错误消息试图传达的内容以及如何解决它。

4

1 回答 1

4

该库似乎正在尝试验证 SSL 证书,但它不能这样做。您可以通过 OAuth::disableSSLChecks 方法禁用 ssl 检查。我假设您正在使用以下 pecl 扩展http://www.php.net/manual/en/class.oauth.php。如果不是,您使用的客户端库应该有一种禁用 SSL 证书验证的方法。

....
...
$oauth = new OAuth(my consumer key, my consumer secret);   
$oauth->disableSSLChecks();
..
...

理想情况下,您会在实例化后立即执行此操作

于 2012-10-11T18:57:05.300 回答