";
if (!$username) echo "No username provided!
";
if (!$password) echo "No password provided!
";
if (!$message) echo "No message provided!
";
return false;
}
// The twitter API address
//$url = 'http://twitter.com/statuses/update.xml';
// Alternative JSON version
$url = 'http://twitter.com/statuses/update.json';
// Set up and execute the curl process
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$url");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
// check for success or failure
if (empty($buffer)) {
if ($verbose) {
echo 'TWITTER POST FAILED
';
echo "$buffer
";
}
return false; # if it failed
} else {
if ($verbose) {
echo 'TWITTER POST SUCCESSFUL
';
//echo "success $buffer";
}
return true;
}
}