Log Errors with Twitter


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function tweet_error ($error, $description) {
  2. $username = 'yourusername';
  3. $password = 'yourpassword';
  4. $status = "#$error - $description";
  5. $update_url = 'http://www.twitter.com/statuses/update.xml'; // http://identi.ca/api/statuses/update.xml will use identi.ca instead.
  6. $curl = curl_init();
  7. curl_setopt($curl, CURLOPT_URL, "$update_url");
  8. curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
  9. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  10. curl_setopt($curl, CURLOPT_POST, 1);
  11. curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status");
  12. curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
  13. $result = curl_exec($curl);
  14. $resultArray = curl_getinfo($curl);
  15. curl_close($curl);
  16. return ($resultArray['http_code'] == 200);
  17. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.