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.
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.
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.