I say class, it’s actually just 1 function for PHP 4+ to allow sending of twitter messages really simply.
Based upon the PHP 5 twitter class by David Grudl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | function twitter_send($message, $user, $pass) { $url = 'https://twitter.com/statuses/update.xml'; $post = array('status' => $message); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERPWD, $user.":".$pass); curl_setopt($curl, CURLOPT_HEADER, FALSE); curl_setopt($curl, CURLOPT_TIMEOUT, 20); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:')); if ($post) { curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, $post); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); // no echo, just return result $result = curl_exec($curl); $ok = curl_errno($curl) === 0 && curl_getinfo($curl, CURLINFO_HTTP_CODE) === 200; return $result; } |
That’s it, and then just a call function to send a message:
twitter_send("Hello World!", "myusername","passwordhere");
Simple!
The function also returns XML from twitter, including data such as followers_count, current description, location, profile_image_url etc, if needed.

Thanks !
Very useful !
____________________
Saguenay-IT, (IT Outsourcing, SOA, PHP, ASP, Flex, ActionScript, JavaScript…)
Doesn’t seem to work any longer.