7
votes

I want my website to automatically post status updates to a particular twitter account using OAuth in PHP.

I test this using a URL

www.mysite.com/update_status

but it asks me for "user name" and "password", which is fine when I am testing it. But my website will not be able to insert this user name and password before posting the status update.

So the question is how can a website which is in the server, automatically post a status update to an account without user filling out the user name and password.

Is there any way to bypass this? I tried saving oAuth tokens, but it's not working.

Thank you for your answer in advance!

4
You should elaborate on "it's not working". Provide relevant code. Also, which (if any) Twitter library are you using? - Matthew Flaschen
sorry. when i say it's not working, I meant it's still asking me for "username" and "password". The website won't be able to fill the username and apssword fields. How do I get around this? - ericbae

4 Answers

3
votes

My recommendation:

1) Use a PHP library like http://github.com/abraham/twitteroauth.

2) Select your app on http://dev.twitter.com/apps and click on "My Access Token".

3) Us that access token as described on http://dev.twitter.com/pages/oauth_single_token.

2
votes

Just tried this and it WORKS! And its SO SIMPLE to use!!

http://ditio.net/2010/06/07/twitter-php-oauth-update-status/

Got it working in under 5mins.

1
votes

xAuth is able to do that, but Twitter only allows it for desktop and mobile apps.
In case you wanna try it, read this article and the API docs.

1
votes

Try it with zend framework. As of version 1.10.8 minimal code required to post on Twitter is:

$token = new Zend_Oauth_Token_Access;
$token->setParams(array(
'oauth_token' => 'REPLACE_WITH_TOKEN',
'oauth_token_secret' => 'REPLACE_WITH_TOKEN_SECRET'
));

$twitter = new Zend_Service_Twitter(array(
'consumerSecret' => 'REPLACE_WITH_CONSUMER_SECRET',
'accessToken' => $token
));

$response = $twitter->status->update('REPLACE WITH MESSAGE');

All tokens and secrets can be accessed after registering your application on http://dev.twitter.com