Connect Twitter API with OAuth using PHP.

Few days back I had connected labs.9lessons application to twitter API via OAuth (open protocal secure authorization). In this post I want to explain how to store twitter oauth_token and secret values in to database and how to update status with your own web application.

hi srinivas, thanks for the wondeful post. but, unfortunately it is giving me an error.Even in the live demo on your site getting the same error. After I click on the "Allow" green button it is taking me to the following url: http://twitter.com/oauth/authorize and getting "temporarly down" error. If I refresh I am getting the below effort."Woah there!This page requires some information that was not provided. Please return to the site that sent you to this page and try again … it was probably an honest mistake."

@Srinivas Tamada, what do one has to do in order to keep the user's data, such that we don't have to get to twitter everytime to authenticate, just like it happens on the labs.9lessons.info section, i tried everytime i have to get to twitter for oauth authentication..thanks for the help

uhm...i got a error message. "This page is no longer valid. It looks like someone already used the token information you provided. Please return to the site that sent you to this page and try again … it was probably an honest mistake."

thank you, this is very nice tutorial. and i like it.But I still do not understand about oauth_token and oauth_token_secret which had been entered into the database. is it the same between oauth_token with consumer_key and consumer_secret with oauth_token_secret?

thank you and so sorry if my english is bad, :( i use google translate to translate my language to english, i'm from indonesia. thank you..

consumer_key and consumer_secret is the access credentials for your App on Twitter. Where as the oauth_token and oauth_token_secret is the credentials for the twitter user that is return by Twitter after authentication.

Every time when you have to push a status update for a user, u don't need his username/password u have to use the oauth_token and oauth_token_secret.

It works almost fine. There is only one problem; As soon as I go to confirm.php my website lost all the sessions, so I can't put the oauth_token and oauth_token_secret in the database, how did you fix that with 9lessons.lab?

hello, I get my consumerKey and consumerSecret key both and i set it in secret.php file then after i get some twitter error like:

This page is no longer valid. It looks like someone already used the token information you provided. Please return to the site that sent you to this page and try again … it was probably an honest mistake.

yahooooooooooooooooo This is worked me Thanks for posting thissince one month i am finding such type of code but not got the successand now by this code it worked for me

The message "You are not logged in" could be come because you not set the page callback properelythats why it happenif you set the page call back toYOURDOMAIN / PATH TO FOLDER/confirm.php then it works fine

Hi,I download the script.I set my call back url to http://mydomain.com/Oauth_9lessons2/confirm.php in my twitter application.

when I start with start.php it take me to login of twitter but when i logged in into the twitter it take me to the confirm.php file but it is blank and also it didn't insert any row to the db.the return url which I got is below.

Nice Piece of code you have there... I used it on my current project and it works just fine. But I have a question. Using the keys stored in the db How can I Display a already connected to twitter message on the scree?

Would appreciate if you reply fas as I'am in a jiffy of a situation here...

There is no request token for this page. That's the special key we need from applications asking to use your Twitter account. Please go back to the site or application that sent you here and try again; it was probably just a mistake.

Anything changed in the last few hours?can any one explain in depth because i m new to the twitter apis.