Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

using php to post to twitter

using php to post to twitter

11:36 pm on Jun 27, 2011 (gmt 0)

Preferred Member

5+ Year Member

joined:June 19, 2006
posts: 476
votes: 0

Ive tried several examples and each time I go to my script it asks me to login with twitter. Is there a way to authorize once and then not have to do it or log in each time?

Im using

But its just a bit over my head. Anyone know of an easy way to use php to post to twitter?


/* If access tokens are not available redirect to connect page. */
if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
header('Location: ./clearsessions.php');
/* Get user access tokens out of the session. */
$access_token = $_SESSION['access_token'];

/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);

/* If method is set change API call made. Test is called by default. */
$content = $connection->get('account/verify_credentials');

/* Some example calls */
$connection->post('statuses/update', array('status' => 'test again'));
11:53 pm on June 27, 2011 (gmt 0)

New User

joined:May 15, 2011
posts: 14
votes: 0

I'd be interested too. I'm trying to Tweet with mySQL through TwitterFeed without much success.