tags:

views:

689

answers:

4

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!

A: 

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.

Jorge
serious? so there is no other way?
ebae
There might be, but i'm not aware of it. A lot of people are confused about how to make the transition to OAuth. Maybe some digging on the Twitter discussion group yields a satisfying answer.
Jorge
Here: http://groups.google.com/group/twitter-development-talk/browse_thread/thread/97889b6fc84c6d53#
Jorge
+1  A: 

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.

abraham
+1  A: 

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.

Sim2K
A: 

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

forcecode