0

I'm trying to authenticate a user via Tumblr PHP API.

I'm getting this error

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)'

When visiting the suggested site this is the explanation of error 60

CURLE_SSL_CACERT (60)

Peer certificate cannot be authenticated with known CA certificates.

I found a similar issue here, but how do I fix mine? Is it the same?

This is the code I'm trying to use

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 . "!";

}
Balloon Fight
  • 661
  • 8
  • 16

1 Answers1

0

This is a duplicate. The answer can be found here

This is the solution

  1. download and extract for cacert.pem here (a clean file format/data)

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

    1. put it in :

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

    2. Add this line to your php.ini

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

    3. restart your webserver/apache

Balloon Fight
  • 661
  • 8
  • 16