Take the 2-minute tour ×

So Im using Abrahams Twitter library like this:


/* Build TwitterOAuth object with client credentials. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);

/* Get temporary credentials. */
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);

/* Save temporary credentials to session. */

switch ($connection->http_code) {
    case 200:
        header('Location: ' . $url); 
        /* Show notification if something went wrong. */

and index.php:

        $userInfo = $connection->get('account/verify_credentials');

But I keep getting the error:

"Could not authenticate you"

What am I doing wrong?

share|improve this question
possible duplicate of "Could not authenticate you." -error when using Twitter OAuth –  ajreal Dec 9 '11 at 18:43
ITs not duplicated. I already apply the solution thats written in that thread :S –  Dbugger Dec 9 '11 at 19:10

1 Answer 1

up vote 0 down vote accepted

Apparently after authentification, I have to replace the temporary authentification token, for a permanent one. Here it is:


/* Create TwitteroAuth object with app key/secret and token key/secret from default phase */

/* Request access tokens from twitter */

$_SESSION['access_token'] = $access_token;

/* Remove no longer needed request tokens */

/* If HTTP response is 200 continue otherwise send to connect page to retry */
if (200 == $connection->http_code) {
    /* The user has been verified and the access tokens can be saved for future use */
    $_SESSION['status'] = 'verified';
    header('Location: ./index.php');
} else {
    die("There was a problem!");
share|improve this answer

Your Answer


