views:

186

answers:

1

I'm writing some backend script for a twitter app and heres how it's going

  1. On the app you click a button that sends you to login.php on my server which logs into my database connects to twitter with my consumer key and secret: $to = new TwitterOAuth($consumer_key, $consumer_secret); $tok = $to->getRequestToken(); $request_link = $to->getAuthorizeURL($tok); and then writes the token and secret to the database, sets a session equal to the id in the database of the token and secret and then redirects to the "$request_link"

  2. You then go through the process of logging in and such on twitter and it redirects you to callback.php on my server

  3. Callback.php consists of logging into the database again, getting the new token and secret, and then writing the new token and secret to the database and then prompts you to go back to the app

  4. Then on the app, all I'm trying to do is access the basic credentials$to->get('account/verify_credentials') and it keeps coming back "could not authenticate you"

What am I doing wrong?? Thank you for all the help :)

+1  A: 

This is how your last $to should be built before calling verify_credentials:

$to = new TwitterOAuth($consumer_key, $consumer_secret, $tok['oauth_token'], $tok['oauth_token_secret']); 
$to->get('account/verify_credentials');

Make sure $tok is the oauth_token and oauth_token_secret you got from:

$tok = $to->getAccessToken();

I assume all the calls are from the same server so there should not be any time sync issues.

abraham