【问题标题】:Fatal error cURL error 60 When Using Tumblr PHP API [duplicate]使用 Tumblr PHP API 时出现致命错误 cURL 错误 60 [重复]
【发布时间】:2018-03-23 21:24:18
【问题描述】:

我正在尝试通过 Tumblr PHP API 对用户进行身份验证。

我收到了这个错误

致命错误:未捕获的异常 带有消息“cURL 错误 60”的“GuzzleHttp\Exception\RequestException”: SSL 证书问题:无法获取本地颁发者证书(请参阅 http://curl.haxx.se/libcurl/c/libcurl-errors.html)'

访问建议的站点时,这是错误 60 的解释

CURLE_SSL_CACERT (60)

对等证书无法使用已知 CA 证书进行身份验证。

我发现了一个类似的问题here,但我该如何解决我的问题?是一样的吗?

这是我正在尝试使用的代码

require_once('vendor/autoload.php');
$consumerKey = 'XXX';
$consumerSecret = 'YYY';
$client = new Tumblr\API\Client($consumerKey, $consumerSecret);
$requestHandler = $client->getRequestHandler();
$requestHandler->setBaseUrl('https://www.tumblr.com/');

// If we are visiting the first time
if (!$_GET['oauth_verifier']) {

    // grab the oauth token
    $resp = $requestHandler->request('POST', 'oauth/request_token', array());
    $out = $result = $resp->body;
    $data = array();
    parse_str($out, $data);

    // tell the user where to go
    echo '<a href="https://www.tumblr.com/oauth/authorize?oauth_token=' . $data['oauth_token'].'"> GO </a>';
    $_SESSION['t']=$data['oauth_token'];
    $_SESSION['s']=$data['oauth_token_secret'];

} else {

    $verifier = $_GET['oauth_verifier'];

    // use the stored tokens
    $client->setToken($_SESSION['t'], $_SESSION['s']);

    // to grab the access tokens
    $resp = $requestHandler->request('POST', 'oauth/access_token', array('oauth_verifier' => $verifier));
    $out = $result = $resp->body;
    $data = array();
    parse_str($out, $data);

    // and print out our new keys we got back
    $token = $data['oauth_token'];
    $secret = $data['oauth_token_secret'];
    echo "token: " . $token . "<br/>secret: " . $secret;

    // and prove we're in the money
    $client = new Tumblr\API\Client($consumerKey, $consumerSecret, $token, $secret);
    $info = $client->getUserInfo();
    echo "<br/><br/>congrats " . $info->user->name . "!";

}

【问题讨论】:

    标签: php ssl curl tumblr guzzle


    【解决方案1】:

    这是重复的。答案可以在here找到

    这就是解决办法

    1. 在此处下载并提取 cacert.pem(干净的文件格式/数据)

      https://gist.github.com/VersatilityWerks/5719158/download

      1. 把它放进去:

        C:\xampp\php\extras\ssl\cacert.pem

      2. 将此行添加到您的 php.ini 中

        curl.cainfo = "C:\xampp\php\extras\ssl\cacert.pem"

      3. 重启你的网络服务器/apache

    【讨论】:

      猜你喜欢
      • 2017-02-13
      • 2012-10-11
      • 1970-01-01
      • 2018-04-23
      • 2020-09-15
      • 2017-12-28
      • 1970-01-01
      • 2011-03-16
      • 1970-01-01
      相关资源
      最近更新 更多