RSS

How To Update Status Via PHP Page On Web

Tue, Jun 8, 2010

Freebies, Misc



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;
}

admin
View all posts by admin
Kashif Mehmoods website
  • Delicious
Share for other World:
  • Digg
  • del.icio.us
  • TwitThis
  • Facebook
  • StumbleUpon
  • Technorati
  • Reddit
  • MySpace
  • Mixx
  • LinkedIn
  • Google Bookmarks
  • Yahoo! Buzz
  • DZone
  • Propeller
  • Design Float
  • Diigo
  • Live
  • Netvibes

Related posts:

  1. Where we can Host a Joomla Website What Is Joomla? When blogging is being discussed, Joomla...
  2. 35+ Web Developers Useful Ajax Tutorials Here is a bundle pack about AJAX Tutorials for...

Related posts brought to you by Yet Another Related Posts Plugin.

, , ,

This post was written by:

admin - who has written 125 posts on Tutorial Lounge.


Contact the author

1 Comments For This Post

  1. deden Says:

    thank for your share… great post…

3 Trackbacks For This Post

  1. Tweets that mention How To Update Status Via PHP Page On Web | Tutorial Lounge -- Topsy.com Says:

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

  2. How To Update Status Via PHP Page On Web | Blog Links Says:

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

  3. for Designers and Developers there are 66 Best Articles Resources | Technology Blog Says:

    [...] How To Update Status Via PHP Page On Web [...]

Leave a Reply