How To Update Status Via PHP Page On Web
admin Posted on 08. Jun, 2010 | Comment in!

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.
Curl
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 = “http://twitter.com/statuses/update.xml?status=“.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_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);$result = curl_exec($ch);
// Look at the returned header
$resultArray = curl_getinfo($ch);curl_close($ch);
if($resultArray['http_code'] == “200″){
$twitter_status=’Your message has been sended! <a href=”http://twitter.com/’.$username.‘”>See your profile</a>’;
} else {
$twitter_status=”Error posting to Twitter. Retry”;
}
return $twitter_status;
}
If you enjoyed reading, consider sharing it on one of these social bookmarking sites.
Enjoy this Post? Subscribe to Tutorial Lounge








Tweets that mention How To Update Status Via PHP Page On Web | Tutorial Lounge -- Topsy.com
June 08, 2010
[...] This post was mentioned on Twitter by Daud and freephptutorial, Nida. Nida said: RT @tutoriallounge How To Update Status Via PHP Page On Web | Tutorial Lounge http://bit.ly/ch2pcd [...]
How To Update Status Via PHP Page On Web | Blog Links
June 12, 2010
[...] How To Update Status Via PHP Page On Web Sharevar fbShare = {url: 'http://bloglinks.ejazahmad.com/how-to-update-status-via-php-page-on-web/',size: 'large',}Save submit_url = 'http://bloglinks.ejazahmad.com/how-to-update-status-via-php-page-on-web/'; VN:F [1.9.1_1087]please wait…Rating: 0.0/10 (0 votes cast)VN:F [1.9.1_1087]Rating: 0 (from 0 votes) Flash, Graphic Design, PHP, Tutorials, Web Design [...]
deden
June 14, 2010
thank for your share… great post…
for Designers and Developers there are 66 Best Articles Resources | Technology Blog
June 21, 2010
[...] How To Update Status Via PHP Page On Web [...]
Johan
September 07, 2010
Above script is not working anymore because twitter need oAuth can you please update this script