Categories
PHP

Fun with Twitter OAuth: The Source Code

In my previous post, I mentioned about the twitter OAuth app hosted at: https://masnun.com/twitter-app/ . Here it comes, the source code.

I am not going to include the Twitter OAuth Library source. You have to download it from Github. The link is available in my previous post.

consumer.php

index.php

return.php

Notes On OAuth:
First we, construct the twitter object with the consumer details.
Then we ask for a request token. We build the authorization url with this token.
We send the user to the auth URL.
When the user returns, again construct a twitter object with consumer details and the request token we retrieved previously.
Now that the user is authorized, we ask for access tokens.
We have the access tokens now, so build a new twitter object that has full access to the API.

Now, we can make API calls.

The steps may seem a bit odd at first look. Just go through a couple of times and you’ll get it clearly.

Enjoy OAuthentication, Enjoy Twitter enginnering !!