Apr
16

How To: Update Your Twitter Status Using PHP.

Author ZeeShaN    Category PHP, Twitter     Tags ,


Twitter is social networking website which keeps your followers with you. Twitter provides an extensive API using which we can update twitter status through PHP code.

// Set your username and password
 
$username = 'YourAccount';
 
$password = 'YourPassword';
 
$message = 'Codeigniter Help'; // Which you want to update
 
$url = 'http://twitter.com/statuses/update.xml';
 
// Set up and execute the curl process
 
$curl_handle = curl_init();
 
curl_setopt($curl_handle, CURLOPT_URL, "$url");
 
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
 
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
 
curl_setopt($curl_handle, CURLOPT_POST, 1);
 
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
 
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
 
$buffer = curl_exec($curl_handle);
 
curl_close($curl_handle);
 
// check for success or failure
 
if (empty($buffer)) {
 
echo 'Failed !';
 
} else {
 
echo 'Status has been updated.';
 
}
 
?>

Add To Facebook Stumble This Digg This Add To Del.icio.us Add To Reddit Add To Yahoo Add To Twitter


Written by ZeeShaN

ZeeShaN RasooL is a web developer who loves to work in latest technologies to create more interactive dynamic and beautiful web pages.







Enter your Email:

Click Here for Popular

Who I Am

Zeeshan Rasool

Software Engineer - PHP
Lahore - Pakistan

zeeshan(@)99points.info
Skype: zeeshan-rasool
gTalk: zishan.rasool85

Categories

Tags

Comments