Problem with statuses/home_timeline


#1

Hi.
Im trying to get the timeline of a specific user. So:
a) I already created my Twitter Application.
b) I already called the oAuth proccess and that returns to me the answer like:

http://(** my domain **)/testes/pp_twitter/index.php?oauth_token=3QFLBxjf******************************fQAj9M&oauth_verifier=Z7Hj7XtV2**********IECvMNVJKMEKndxHkqjeMoM 

c) Since I get those tokens (oauth_token and oauth_verifier) i call the method statuses_homeTimeline() of the library Codebird (as suggested in the Twitter Developer website).

My code is like this:

if (! isset($_GET['oauth_verifier'])) {
    // gets a request token
    $reply = $cb->oauth_requestToken(array(
        'oauth_callback' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']
    ));

    // stores it
    $cb->setToken($reply->oauth_token, $reply->oauth_token_secret);
    $_SESSION['oauth_token'] = $reply->oauth_token;
    $_SESSION['oauth_token_secret'] = $reply->oauth_token_secret;

    // gets the authorize screen URL
    $auth_url = $cb->oauth_authorize();
    header('Location: ' . $auth_url);
    die();

} else {

    // gets the access token
    $cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
    $reply = $cb->oauth_accessToken(array(
        'oauth_verifier' => $_GET['oauth_verifier']
    ));
    
    $_SESSION['oauth_token'] = $reply->oauth_token;
    $_SESSION['oauth_token_secret'] = $reply->oauth_token_secret;


    // Here I call the timeline posts:
    $status = (object) $cb->statuses_homeTimeline();
    $status = json_encode($status);
}

But it always returns

    {"errors":[{"message":"Invalid or expired token","code":89}],"httpstatus":401} or "Bad Authentication"message.

Any help is very appreciate.
Thank you.

Pedro Paulo Almeida
Brazil