From 5295dfe4e6c6a7917ab033008b5d9c15a79b91ca Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Sun, 19 Jul 2009 13:31:21 -0400 Subject: [PATCH] Add destroy(), show() methods and fill in update() to include a in_reply_to parameter --- .../lib/Horde/Service/Twitter/Statuses.php | 40 ++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/framework/Service_Twitter/lib/Horde/Service/Twitter/Statuses.php b/framework/Service_Twitter/lib/Horde/Service/Twitter/Statuses.php index 0b1771740..55d94460f 100644 --- a/framework/Service_Twitter/lib/Horde/Service/Twitter/Statuses.php +++ b/framework/Service_Twitter/lib/Horde/Service/Twitter/Statuses.php @@ -12,6 +12,9 @@ class Horde_Service_Twitter_Statuses { + private $_endpoint = 'http://twitter.com/statuses/'; + private $_format = 'json'; + public function __construct($twitter) { $this->_twitter = $twitter; @@ -24,12 +27,45 @@ class Horde_Service_Twitter_Statuses */ public function show($id) { + $url = $this->_endpoint . '/destroy.' . $this->_format; + return $this->_twitter->request->post($url, array('id' => $id)); + } + /** + * Destroy the specified status update, obviously only if the current user + * is the author of the update. + * + * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0destroy + * + * @param string $id The status id + * + * @return string + */ + public function destroy($id) + { + $url = $this->_endpoint . '/destroy.' . $this->_format; + return $this->_twitter->request->post($url, array('id' => $id)); } - public function update($status) + /** + * Update the current user's status. + * + * @param string $status The new status text. + * @param string $replyTo If specified, *and* the text of the status contains + * a mention of the author of the replied to status + * (i.e. `@username`) this update will be "in reply to" + * the specifed status message id. + * + * @return string + */ + public function update($status, $replyTo = '') { $url = 'http://twitter.com/statuses/update.json'; - return $this->_twitter->request->post($url, array('status' => $status)); + $params = array('status' => $status); + if (!empty($replyTo)) { + $params['in_reply_to_status_id'] = $replyTo; + } + + return $this->_twitter->request->post($url, $params); } } -- 2.11.0