The easiest way to use Twitter REST API v1.1 in PHP, Login with Twitter, Follow and Unfollow, Post Tweets, & More! Without PHP cURL.

How to use Twitter REST API in PHP

Using “QassimTwitterOAuth” you can use Twitter REST API in PHP, and create any Twitter App! You can create follow and unfollow app, post a new tweets, get recent tweets, login with twitter in your website, and more (FULL REST API).

QassimTwitterOAuth is easy to use, we will learn how to use it, with 3 examples: login with Twitter in your website, post tweets, and get recent tweets.

Twitter App

Firstly go to Twitter App and create a new App, read this post about how to create a new Twitter App.


Download QassimTwitterOAuth and unzip it, now open file “config.php”:

$callback_url = ''; // enter your callback link
$consumer_key = 'XXXXXX'; // enter your consumer key
$consumer_secret = 'XXXXXX'; // enter your consumer secret

Enter your consumer key and consumer secret, and enter your callback URL.

Note: In localhost your callback domain must to be “” not “http://localhost”.

Now your App is ready.


QassimTwitterOAuth has 3 examples:

  1. Login with Twitter (with logout and display user profile).
  2. Post Tweets (POST Method Example).
  3. Display Recent Tweets (GET Method Example).

Note: You can also use DELETE Method.

To login with Twitter, just open this link:

Live Demo of Login with Twitter.

To post a new tweet (POST Method) firstly login with your Twitter account in localhost and open this link:

Open file “post_tweet_example.php” and read the code to learn how to post a new tweet using QassimTwitterOAuth.

To display recent tweets (GET Method) login with your Twitter account and open this link:

Open file “recent_tweets_example.php” and read the code to learn how to use GET Method in QassimTwitterOAuth.

Anyway if you don’t want REST API you can use QassimTwitterOAuth for Login with Twitter in your website.


Tutorials about How to Login with Instagram, Facebook, SoundCloud, Google, LinkedIn, Dropbox, in your website using API.