On 11th June 2013, Twitter officially closed its V1.0 API and has now migrated to the v1.1 API. This means that we need to authenticate users before being able to display Tweets from a user's profile, even it is a public profile. Yes, you read it correctly; even if the user's profile is a public profile. This means that to get Tweets from any Twitter user's timeline, we will need to make an authenticated request via oAuth. In case you want to understand what oAuth is all about, read it here.
This article will explain to you how to authenticate your website / application to display Tweets from your timeline. In case you are just interested in displaying Tweets from your timeline on your website and nothing much, you do not need to dig into this article, rather you can do it using Twitter Widgets and if you are not happy with the way it looks on your website and you want to customize it, read this article on customizing the embedded widget.
If you are more technical, read on! To be able to connect Twitter using oAuth, we need to do the following 2 very important things:
- Create a Twitter App
- Connect with the App using a library in the language of your choice.
The very first thing that you will need to do is to create an app on Twitter. So, let us start building an app on Twitter. To create an app on Twitter, use the following procedure:
- Go to https://dev.twitter.com/apps and log in with your Twitter credentials.
- Since this is the first time you are logging into this screen, you will see a button to "Create a new application":
- Enter the following details on this screen:
- Name: Enter a name to your Twitter app
- Description: Provide a short description to your app
- Website: Normally the website address where you will want your app to be running on (in other words, where you want to display your Tweets)
- Callback URL: Can be left empty
- Agree to the "Developer Rules of the Road"
- Hit "Create your Twitter Application". You will see a message that your app has been created successfully and you will see you Consumer Key and Consumer Secret.
- At the bottom of the page. Click "Create my access token". You will see a message that your token has been successfully created.
- Once that is done, go to the "OAuth Tool" tab of your app and copy the following fields to be used in your application:
- You are ready to code some lines in your application to get data from your timeline.
Hope you like this article!