Posted By

iTony on 03/18/09


Tagged

errors php log twitter


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

wizard04
jfherring
lajevardi
kenton
jealousy


Log Errors with Twitter


 / Published in: PHP
 

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

  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. }

Report this snippet  

You need to login to post a comment.