php - 使用 Tumblr PHP API 时出现 fatal error cURL 错误 60

标签 php ssl curl tumblr guzzle

<分区>

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

我遇到了这个错误

Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)'

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

CURLE_SSL_CACERT (60)

Peer certificate cannot be authenticated with known CA certificates.

我发现了一个类似的问题 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 . "!";

}

最佳答案

这是重复的。答案可见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

关于php - 使用 Tumblr PHP API 时出现 fatal error cURL 错误 60,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46701147/

上一篇:ssl - 具有自定义 TLS 证书链的 OpenShift Web 控制台仍然是 "unsecured"

下一篇:Java Web 服务 - Android 应用程序 HTTPS/SSL

相关文章:

ssl - 安装SSL证书后firefox打不开网站

azure - azure cloudapp.net 的 SSL 证书

linux - 运行 curl 命令时需要绕过 Location

curl - 在 Jenkins 的失败/成功中转换 curl 请求作业

php - PHP : Error: Expected an order id to be passed 中的 Paypal 智能按钮服务器集成

php - CodeIgniter - 在文本框中输入数据并在提交时检查数据库中的匹配记录

php - 检测提交文本中使用的字母表(论坛/博客)

php - IIS7 上带有漂亮 url(url 重写)的 WordPress Gravity 表单

java - 什么是 "trustAnchors"

docker - 无法使用 Docker Compose 提供的 Drupal 应用程序从 API 获取或发布数据