الثلاثاء، 24 أغسطس 2010

يمكنك تغيير حالتك فى ال تويتر مستخدماpost status through PHP web page to twitter

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! See your profile’;
} else {
$twitter_status=”Error posting to Twitter. Retry”;
}
return $twitter_status;
}

ليست هناك تعليقات:

إرسال تعليق