Twitter log writer
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 2526 27 28 29 3031 32 33 | <?php class Sozfo_Log_Writer_Twitter extends Zend_Log_Writer_Abstract { protected $_username; protected $_password; protected $_twitter; public function __construct ($username, $password) { $this->_username = $username; $this->_password = $password; $this->_formatter = new Zend_Log_Formatter_Simple(); } protected function _getTwitter () { if (null === $this->_twitter) { $this->_twitter = new Zend_Service_Twitter($this->_username, $this->_password); $response = $this->_twitter->account->verifyCredentials(); if ($response->isError()) { throw new Zend_Log_Exception('Provided credentials for Twitter log writer are wrong'); } } return $this->_twitter; } public function _write ($event) { $line = $this->_formatter->format($event); $this->_getTwitter()->status->update($line); } } |
Comments
You must login before commenting on a snippet. If you do not have an account, please register.
Snippet description
This log writer allows you to push the messages to a Twitter user. This user updates his timeline with the message.
Support for Zend_Log_Formatter_Simple is available. It is recommended to log only some types (filter them with Zend_Log_Filter) because connecting to Twitter for every simple (stupid) message is a waste of resources.
More information at my Google code project: http://code.google.com/p/sozfo
Snippet details
- Created:
-
Jurian
- Edited:
-
Jurian
- Revision Id:
- 131
- Edit Message:
- Initial Release
- ZF Version
- 1.8.3
- Tags:
- twitter log writer
- Comments:
- 0
- Views:
- 282
- Points:
- 0 (0 votes)