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.
QassimTwitterOAuth
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.
Examples
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:
http://127.0.0.1/qassim-twitter-oauth/login.php
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:
http://127.0.0.1/qassim-twitter-oauth/post_tweet_example.php
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:
http://127.0.0.1/qassim-twitter-oauth/recent_tweets_example.php
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.
More
Tutorials about How to Login with Instagram, Facebook, SoundCloud, Google, LinkedIn, Dropbox, in your website using API.