Wednesday , 26 April 2017
Home » PHP » [PHP] Connect to Twitter OAuth API
[PHP] Connect to Twitter OAuth API

[PHP] Connect to Twitter OAuth API

Hi Friends,

I have recently implemented Twitter OAuth API in one of my client’s web application. Here I will show you how to connect with Twitter OAuth API using PHP and save the oauth_token and oauth_token_secret in MySql database. oauth_token and oauth_token_secret will be used whenever you want to update status in Twitter via your web application.

Step #1
You need to create table in your database first. Here is MySql query for that.

CREATE TABLE users
(
uid INT PRIMARY KEY AUTO_INCREMENT,
uname VARCHAR(50) UNIQUE,
passcode VARCHAR(50),
oauth_token VARCHAR(90),
oauth_token_secret VARCHAR(90)
);

Please download this zip file with all source files inside.

Download Connect to Twitter OAuth API Script

You will find confirm.php file which is Callback URL called after successfully authentication of Twitter OAuth API. In the confirm.php file, we are saving the oauth_token and oauth_token_secret in our database table created above and also generate the cookie for it.

Now you can find update.php file which is used to post status message on Twitter from your web application. All you need to do is set $message variable dynamically to whatever message you want to send.

This tutorial includes how to Connect to Twitter OAuth API using PHP, Connect to Twitter OAuth API, Connect to Twitter OAuth API Script, Send Message to Twitter using API, Send Automatic message to Twitter App, PHP Script to update status in Twitter.

      
Plugin by: PHP Freelancer

About Rakshit Patel

I am PHP Freelancer, Rakshit Patel working as PHP Programmer India. I have developed this site to share my knowledge, thoughts and experience during the development of projects. We are group of developers working together. If you want to hire us for any PHP related work, you can reach me via Email, Phone or Chat.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.