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.
Download QassimTwitterOAuth and unzip it, now open file “config.php”:
$callback_url = 'http://127.0.0.1/qassim-twitter-oauth/callback.php'; // 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 “http://127.0.0.1/” not “http://localhost”.
Now your App is ready.
QassimTwitterOAuth has 3 examples:
- Login with Twitter (with logout and display user profile).
- Post Tweets (POST Method Example).
- 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.