Using Twitter OAuth to automatically update status

I want my site to automatically send status updates to a specific Twitter account using OAuth in PHP.

I am testing this with a URL

www.mysite.com/update_status

but it asks me for a "username" and "password", which is great when I test it. But my site will not be able to insert this username and password before posting the status update.

So, the question is how the website that is on the server automatically publishes a state update for the account without entering the user name and password.

Is there any way around this? I tried to save tokens, but it does not work.

Thanks for your reply in advance!

+7
php oauth twitter
source share
4 answers

My recommendation:

1) Use a PHP library, for example http://github.com/abraham/twitteroauth .

2) Select your application at http://dev.twitter.com/apps and click on "My access token."

3) We need this access token, as described in http://dev.twitter.com/pages/oauth_single_token .

+3
source share

Just tried it and it WORKS! And its SO EASY to use !!

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

Got a job under the age of 5 minutes.

+2
source share

xAuth can do this, but Twitter only allows for desktop and mobile applications.
If you want to try, read this article and the API docs .

+1
source share

Try using the zend framework. Starting with version 1.10.8, the minimum code required for publishing on Twitter:

$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 obtained after registering your application at http://dev.twitter.com

+1
source share

All Articles