简体   繁体   English

LinkedIn Api - 未捕获的异常'OAuthException'

[英]LinkedIn Api - Uncaught exception 'OAuthException'

I'm currently attempting to install a login button for LinkedIn onto my website. 我目前正在尝试将LinkedIn的登录按钮安装到我的网站上。 I'm trying to go step by step as the developers section shows. 正如开发人员部分所示,我正在尝试一步一步走。 After I wrote the code to get a request token and checked it using print_r. 在我编写代码以获取请求令牌并使用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";

I got "Fatal error:Uncaught exception 'OAuthException'...Peer certificate cannot be authenticated with known CA certificates". 我收到了“致命错误:未捕获的异常'OAuthException'...对等证书无法使用已知的CA证书进行身份验证”。 The line that was called for the error is below 调用错误的行如下所示

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

I am not understanding what that error is trying to tell me so that I can fix the problem. 我不明白该错误试图告诉我什么,以便我可以解决问题。 I would appreciate and tips or guidance to help me better understand what this error message is trying to convey and how to fix it. 我将不胜感激,提示或指导,以帮助我更好地了解此错误消息试图传达的内容以及如何解决它。

It seems that the library is trying to verify the SSL certificate and it cannot do so. 似乎该库正在尝试验证SSL证书,但它无法执行此操作。 You could disable ssl checks via the method OAuth::disableSSLChecks. 您可以通过OAuth :: disableSSLChecks方法禁用ssl检查。 I assume you are using the following pecl extension http://www.php.net/manual/en/class.oauth.php . 我假设您使用以下pecl扩展名http://www.php.net/manual/en/class.oauth.php If not the client library you are using should have a method to disable the SSL certificate verification. 如果不是您正在使用的客户端库应该有一种方法来禁用SSL证书验证。

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

Ideally you would do it right after instantiation 理想情况下,您可以在实例化后立即执行此操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM