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

标签 php api oauth linkedin fatal-error

我目前正尝试在我的网站上安装 LinkedIn 的登录按钮。正如开发人员部分所示,我正在尝试逐步进行。在我编写代码以获取请求 token 并使用 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";

我收到“ fatal error :未捕获异常‘OAuthException’...无法使用已知 CA 证书对对等证书进行身份验证”。错误调用的行在下面

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

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

最佳答案

似乎图书馆正在尝试验证 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();
..
...

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

关于php - LinkedIn Api - 未捕获的异常 'OAuthException',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12846458/

相关文章:

api - 如何使用github API从github的URL获取主要语言或语言列表?

php - WooCommerce API 返回 404 未找到

javascript - API Jive 获取类别错误 : Uncaught Passed URI does not match "/places/{uri}":/api/core/v3/places/

php - 如何在 PHP 中将十六进制转换为二进制?

php - Bootstrap 提前输入仅显示结果的第一个字符

security - 如何在 Haskell 中对字符串的 SHA256 哈希进行 Base64 UrlEncode?

html - 在 cookie 中存储 OAuth token 是不好的做法吗?

javascript - 尽管在沙盒环境中工作良好,但我无法在生产环境中获得 token

php - 具有 "template"功能和 JQuery 和 PHP 视觉帮助的 Dreamweaver 的替代品

php - 代码点火器 : Resetting the form values