Add destroy(), show() methods and fill in update() to include a in_reply_to parameter
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 19 Jul 2009 17:31:21 +0000 (13:31 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 19 Jul 2009 17:31:21 +0000 (13:31 -0400)
framework/Service_Twitter/lib/Horde/Service/Twitter/Statuses.php

index 0b17717..55d9446 100644 (file)
@@ -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);
     }
 }