Here we will show to post tweet on twitter using twitter oAuth API and PHP. Twitter is a microblogging website where you can show yourself within the character limit of 140 characters. Twitter is the easiest way to see what’s going on in the world in real time and has become very popular. Here we are going to tell you how you can add facility of post tweet on twitter from your website.

Firstly you have to login through twitter API by entering your username and password after that write post or message what you want will be updated on your twitter timeline. You do not need to go on twitter to update tweet by just clicking on loginbutton and write post or message into text area you can achieve that thing.

Here we are telling you step by step that how you can do this thing as follows:

1. Login from your twitter account and go to to create new app. Fill all details like app name, redirect url and website url. App name will show when user will login through app so give name what you want to show there. In my case app name is discussdesk_twitter.

2. After submitting form you will have following screen as shown below. Here you are seeing consumer key and secret key will use in your project further.

3. Create file config.php with following code as shown below as follows. Here you have to put api and secret key of application in line no. 2 and 3 respectively. Redirect url will put in line no. 4 in define method.

4. Create another file index.php with following code as shown below. it is used to render login button like by clicking user will go on twitter site after that taking authentication will come back to index.php page and show textarea and button to update tweet on twitter.

5. Create another file process.php to check and save user access token with following code as shown below.

6. To destroy the user session we will create another file called logout.php with following code as shown below:

Hope this tutorial will useful for you still have any query regarding twitter api feel free to comment below.