How to get the right access token and secret?


#1

Hi all!

I am confused. I use the piece of php script below to acquire the keys and the secret.
Then when I use these keys and secret to post an update, I receive an error the error displayed as an object.

What am I doing wrong?

object(stdClass)#8 (1) {
  ["errors"]=>
  array(1) {
    [0]=>
    object(stdClass)#6 (2) {
      ["message"]=>
      string(24) "Invalid or expired token"
      ["code"]=>
      int(89)
    }
  }
}


<?php
require('twitter/twitteroauth.php'); 
require('config/twconfig.php');
session_start();
$twitteroauth = new TwitterOAuth(MY_CONSUMER_KEY, MY_CONSUMER_SECRET); 
$request_token = $twitteroauth->getRequestToken($website['url'].'/getTwitterData.php'); 

$_SESSION['oauth_token'] = $request_token['oauth_token']; 
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
if ($twitteroauth->http_code == 200) {
    $url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']); 
    header('Location: '.$url); 
} else { 
    die('Error'); 
}
?>