I'm a newbie with the Twitter API. I have no problem sending a user from my site to Twitter via the api and receiving authentication. Here is the code I use for that, tweaked from Nettus.
<?php // Twitter API Example--Nettuts session_start(); require_once('inc/twitterOAuth.php'); // make sure you swap these for your own! $consumer_key = '* * * *'; $consumer_secret = '* * *'; // create some request tokens $toa = new TwitterOAuth($consumer_key, $consumer_secret); $tokens = $toa->getRequestToken(); // store it in our session $_SESSION['oauth_request_token'] = $tokens['oauth_token']; $_SESSION['oauth_request_token_secret'] = $tokens['oauth_token_secret']; $_SESSION['oauth_state'] = 'SENT'; // send the user on their way header('Location: '.$toa->getAuthorizeURL($tokens['oauth_token'])); ?> OK, no problem. However, I cannot then use the tokens I receive back from twitter to make a connection. Here is the code I am trying to use. <html> <head> <title>PHP test post to Twitter</title> </head> <body> <table width="70%" align="center"><tr><td> <br><br> stuff starts here <br><br> <?php // $val1 = $_GET['ot']; // $val2 = $_GET['ov']; echo 'step one ... <br><br>'; require_once('inc/twitterOAuth.php'); require_once('inc/config.php'); echo 'step two ... <br><br>'; // $CONSUMER_KEY = '* * * *'; // $CONSUMER_SECRET = '* * * *'; // $OAUTH_TOKEN = '* * * *'; // $OAUTH_SECRET = '* * * *'; define("CONSUMER_KEY", "* * * "); define("CONSUMER_SECRET", "* * * *"); define("OAUTH_TOKEN", "* * * *"); define("OAUTH_SECRET", "* * * *"); echo 'step three ...<br><br>'; $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET); $content = $connection->get('account/verify_credentials'); echo 'step four ...<br><br>'; $connection->get('users/show', array('screen_name' => $_REQUEST['screen_name'])); $login_status = "Hi ".$_SESSION['OAUTH_TOKEN']['screen_name'].", are you ready to archive?<br><a href='./clearsessions.php'>logout</a>"; $logged_in = TRUE; ?> <br> <?php echo $login_status; ?> <br><br> stuff ends here. </td></tr></table> </body> </html> The page stops loading after >> echo 'step three ...<br><br>'; << and goes blank. Anyone have an idea why these two lines do not work-- $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET); $content = $connection->get('account/verify_credentials'); Is the problem that I am missing a step? All I got in step 1 was a request token but not an access token? Thanks, Joe p.s. Apologies to the mod for sending my cons sec key with the post. Not a good idea to post code at in the wee hours, especially a sat night. -- Twitter developer documentation and resources: http://dev.twitter.com/doc API updates via Twitter: http://twitter.com/twitterapi Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list Change your membership to this group: http://groups.google.com/group/twitter-development-talk