How To Update Status Via PHP Page On Web

Author: | Posted in Freebies 2 Comments

In this article to post status through PHP web page to twitter is so easy just in a 30 minute practice .you will update your status by my script below, you have to need to know about the Curl.

Hope you will learn from these useful techniques and also share your experience about that.


PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols

curl is a command line tool for transferring data with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS, FILE, IMAP, SMTP, POP3 and RTSP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos…), file transfer resume, proxy tunneling and a busload of other useful tricks.

Curl is free and open software that compiles and runs under a wide variety of operating systems. Curl exists thanks to efforts from many contributors.

The most recent stable version of curl is version 7.20.1, released on 14th of April 2010. Currently, 69 of the listed archives are of the latest version.

My function have three parameters first is twitter login id,twitter password and third one is the message you want to sent on twitter

function postToTwitter($username,$password,$message){

$host = ““.urlencode(stripslashes(urldecode($message)));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, “$username:$password”);
curl_setopt($ch, CURLOPT_POST, 1);

$result = curl_exec($ch);
// Look at the returned header
$resultArray = curl_getinfo($ch);


if($resultArray[‘http_code’] == “200”){
$twitter_status=’Your message has been sended! <a href=”’.$username.‘”>See your profile</a>’;
} else {
$twitter_status=”Error posting to Twitter. Retry”;
return $twitter_status;

  1. Posted by deden
  2. Posted by Johan

Add Your Comment