<分区>
<分区>
我正在尝试通过 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
这是解决方案
在此处下载并提取 cacert.pem(干净的文件格式/数据)
把它放在:
C:\xampp\php\extras\ssl\cacert.pem
将此行添加到您的 php.ini
curl.cainfo = "C:\xampp\php\extras\ssl\cacert.pem"
重新启动您的网络服务器/apache
关于php - 使用 Tumblr PHP API 时出现 fatal error cURL 错误 60,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46701147/