Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codebird-php Twitter app. Error 77 while validating the Twitter API certificate

Tags:

php

twitter

I'm trying to make a basic app which authenticates with Twitter, and posts a message on a user's behalf via the library codebird-php (https://github.com/mynetx/codebird-php)

I have copypasted the example code shown on the readme, and changed YOURKEY and YOURSECRET with my app's key and secret.

Everything should work fine but when I load my page, I get a message saying : Error 77 while validating the Twitter API certificate.

I can't find this error type anywhere on google... The meaning is quite obvious but I have no idea how to solve it. Any thoughts?

Code is as follows :

require_once ('codebird.php');
\Codebird\Codebird::setConsumerKey('YOURKEY', 'YOURSECRET'); // I changed it to my   settings

$cb = \Codebird\Codebird::getInstance();
session_start();

if (! isset($_SESSION['oauth_token'])) {
// get the request token
$reply = $cb->oauth_requestToken(array(
    'oauth_callback' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']
));

// store the token
$cb->setToken($reply->oauth_token, $reply->oauth_token_secret);
$_SESSION['oauth_token'] = $reply->oauth_token;
$_SESSION['oauth_token_secret'] = $reply->oauth_token_secret;
$_SESSION['oauth_verify'] = true;

// redirect to auth website
$auth_url = $cb->oauth_authorize();
header('Location: ' . $auth_url);
die();

} elseif (isset($_GET['oauth_verifier']) && isset($_SESSION['oauth_verify'])) {
// verify the token
$cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
unset($_SESSION['oauth_verify']);

// get the access token
$reply = $cb->oauth_accessToken(array(
    'oauth_verifier' => $_GET['oauth_verifier']
));

// store the token (which is different from the request token!)
$_SESSION['oauth_token'] = $reply->oauth_token;
$_SESSION['oauth_token_secret'] = $reply->oauth_token_secret;

// send to same URL, without oauth GET parameters
header('Location: ' . basename(__FILE__));
die();
}

// assign access token on each page load
$cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
like image 323
xShirase Avatar asked Jun 16 '13 12:06

xShirase


1 Answers

Solved, I had to have the .pem which wasn't included in the package I downloaded. Conclusion : Never download from untrusted sources!

like image 51
xShirase Avatar answered Sep 30 '22 07:09

xShirase