Posting to twitter from a PHP application


In this article you can learn how to post a status update to twitter from a PHP application.


First you have to create a app in twitter. For that go to and sign in with your twitter account.

Go to “My applications” and use “Create a new application” option to create a new twitter application. Keep the application access level to “Read and write”. So that we can write to twitter by using this app.


[ Note: Twitter app do not allow you to use localhost as domain or call back URL. In this example i have used ]


There are several PHP libraries available for twitter integration. You can find here :

In this article i have used Abraham Williams API Library. You can download it here :

Download the library and grab “twitteroauth” folder and place it in your project folder. Now create index.php and place following code. Replace CONSUMER_KEY, CONSUMER_SECRET, CALLBACK_URL with your twitter app details.

Now execute the URL. You will be redirected to twitter to authenticate.


Once you done it you can see the form by which you can post to twitter.



Share on :