【问题标题】:LinkedIn Api - Uncaught exception 'OAuthException'LinkedIn Api - 未捕获的异常“OAuthException”
【发布时间】:2023-03-16 18:37:01
【问题描述】:

我目前正在尝试在我的网站上安装 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');

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

【问题讨论】:

  • 常量声明似乎是错误的,因为它没有常量的随附值,请检查此页面 developer.linkedin.com/documents/getting-oauth-token-php 中的声明跨度>

标签: php api oauth linkedin fatal-error


【解决方案1】:

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

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

【讨论】:

  • 我应该如何调用该方法?
  • @Octavius $oauth->disableSSLChecks();
  • 输入代码并得到未捕获的异常 'OAuthException' 和消息'无效的身份验证/错误请求???
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-11
  • 2020-08-04
  • 1970-01-01
  • 2014-08-19
  • 1970-01-01
  • 2010-09-28
相关资源
最近更新 更多