Return to Snippet

Revision: 12557
at March 18, 2009 22:57 by iTony


Initial Code
function tweet_error ($error, $description) {
	$username = 'yourusername';
	$password = 'yourpassword';
	$status = "#$error - $description";
	$update_url = 'http://www.twitter.com/statuses/update.xml'; // http://identi.ca/api/statuses/update.xml will use identi.ca instead.
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, "$update_url");
	curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($curl, CURLOPT_POST, 1);
	curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status");
	curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
	$result = curl_exec($curl);
	$resultArray = curl_getinfo($curl);
	curl_close($curl);
	return ($resultArray['http_code'] == 200);
}

Initial URL
http://www.bradshawenterprises.com/blog/2009/how-to-use-twitter-as-an-error-log/

Initial Description

                                

Initial Title
Log Errors with Twitter

Initial Tags
php, log, twitter

Initial Language
PHP