4

I'm creating a web app that will use Twitter API's and OAuth so that my app can post to my users twitter accounts.

Here is where I'm at so far - I get to the twitter authorization page.

Authorize the app to be able to post to my twitter account, which sends me to my callback file.

Get the oath_token and oauth_verifier info.

That's where I'm stuck. I CAN NOT seem to get the access token. Here is my callback code:

include 'db.php';
include 'EpiCurl.php';
include 'EpiOAuth.php';
include 'EpiTwitter.php';
include 'secret.php';


$Twitter = new EpiTwitter($consumerKey, $consumerSecret);


// user comes from twitter
$Twitter->setToken($_GET['oauth_token']);
$token = $Twitter->getAccessToken();
setcookie('oauth_token', $token->oauth_token);
setcookie('oauth_token_secret', $token->oauth_token_secret);
$Twitter->setToken($token->oauth_token, $token->oauth_token_secret);

I've been researching and testing for about 5 hours and still nothing. I have tried to echo $token and it just comes out empty.

Am I missing something big here? seems like an easy task..? Thank you so much for any help :))))

In silico
  • 51,091
  • 10
  • 150
  • 143
  • have you tried changing the include to require_once, maybe some of the files aren't being included? Otherwise have a look at my answer at http://stackoverflow.com/questions/6686176/php-twitter-oauth-automated-tweets/6686409#6686409 It uses Zend, it is REAL easy to setup. – Stephan Aug 16 '11 at 05:51

1 Answers1

1

Try this:

  $Twitter = new EpiTwitter($consumerKey, $consumerSecret);


  // user comes from twitter
  $Twitter->setToken($_GET['oauth_token']);

  $oauth_verifier = $_GET['oauth_verifier'];
  $token = $Twitter->getAccessToken(array('oauth_verifier' => $oauth_verifier));

  $Twitter->setToken($token->oauth_token, $token->oauth_token_secret);

  $creds = $Twitter->get('/account/verify_credentials.json');

Hope it helps.

andrebola
  • 383
  • 2
  • 9