Access Token


Im using Abraham William’s Twitter PHP Library for oauth, I managed to get authorized and get a access token after reading lots of tutorials. But I want to put everything in a single page except library files. Lots of time I tried to do that with my very own class and functions. But so badly still im faild to generate a valid access token.

function getConnectionWithAccessToken($oauth_token, $oauth_token_secret) {
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $oauth_token, $oauth_token_secret);
  return $connection;
$connection = getConnectionWithAccessToken("abcdefg", "hijklmnop");
$content = $connection->get("statuses/home_timeline");

(Source :

I tried to generate a valid oauth token and oauth token secret before “getConnectionWithAccessToken” function execute but I got “Invalid or expired token” error.

Can anyone help me to generate a valid $oauth_token & $oauth_token_secret to generate a valid access token ??



I have generated access token and secret key by registering my application to twitter. It provides you a consumer key and secret too.
I am also using the above code with my credentials and things are working fine.