Add support for a bunch of new methods that will be added soon to the
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 16 Aug 2009 13:55:14 +0000 (09:55 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 16 Aug 2009 13:56:48 +0000 (09:56 -0400)
official twitter statuses/* API.

home_timeline
retweeted_by_me
retweeted_to_me
retweets_of_me
retweet

framework/Service_Twitter/lib/Horde/Service/Twitter/Statuses.php

index bed0f50..6dd8426 100644 (file)
@@ -74,6 +74,12 @@ class Horde_Service_Twitter_Statuses
      *
      * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-friends_timeline
      *
+     * NOTE: According to the API docs, this method is deprecated and will be
+     * going away in a future version of the API. This is to be replaced by
+     * home_timeline.
+     *
+     * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-home_timeline
+     *
      * @param array $params  Parameters for the friends_timeline call
      *   <pre>
      *     since_id   - Only tweets more recent the indicated tweet id
@@ -81,7 +87,8 @@ class Horde_Service_Twitter_Statuses
      *     count      - Only return this many tweets (twitter limit = 200)
      *     page       - The page number to return (note there are pagination limits)
      *   </pre>
-     * @return unknown_type
+     *
+     * @return string
      */
     public function friendsTimeline($params = array())
     {
@@ -90,6 +97,103 @@ class Horde_Service_Twitter_Statuses
     }
 
     /**
+     * Returns the 20 most recent statuses, including retweets, posted by the
+     * authenticating user and that user's friends. This is the equivalent of
+     * /timeline/home on the Web.
+     *
+     * http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-home_timeline
+     *
+     * @param array $params  Parameters for the friends_timeline call
+     *   <pre>
+     *     since_id   - Only tweets more recent the indicated tweet id
+     *     max_id     - Only tweets older then the indeicated tweet id
+     *     count      - Only return this many tweets (twitter limit = 200)
+     *     page       - The page number to return (note there are pagination limits)
+     *   </pre>
+     *
+     * @return string
+     */
+    public function homeTimeline($params = array())
+    {
+        $url = $this->_endpoint . 'home_timeline.' . $this->_format;
+        return $this->_twitter->request->get($url, $params);
+    }
+
+    /**
+     * Returns the 20 most recent retweets posted by the authenticating user.
+     *
+     * @param array $params  Parameters for the friends_timeline call
+     *   <pre>
+     *     since_id   - Only tweets more recent the indicated tweet id
+     *     max_id     - Only tweets older then the indeicated tweet id
+     *     count      - Only return this many tweets (twitter limit = 200)
+     *     page       - The page number to return (note there are pagination limits)
+     *   </pre>
+     *
+     * @return string
+     */
+    public function retweetedByMe($params = array())
+    {
+        $url = $this->_endpoint . 'retweeted_by_me.' . $this->_format;
+        return $this->_twitter->request->get($url, $params);
+    }
+
+    /**
+     * Returns the 20 most recent retweets posted by the authenticating user's
+     * friends.
+     *
+     * @param array $params  Parameters for the friends_timeline call
+     *   <pre>
+     *     since_id   - Only tweets more recent the indicated tweet id
+     *     max_id     - Only tweets older then the indeicated tweet id
+     *     count      - Only return this many tweets (twitter limit = 200)
+     *     page       - The page number to return (note there are pagination limits)
+     *   </pre>
+     *
+     * @return string
+     */
+    public function retweetedToMe($params = array())
+    {
+        $url = $this->_endpoint . 'retweetedToMe.' . $this->_format;
+        return $this->_twitter->request->get($url, $params);
+    }
+
+    /**
+     * Returns the 20 most recent tweets of the authenticated user that have
+     * been retweeted by others.
+     *
+     * @param array $params  Parameters for the friends_timeline call
+     *   <pre>
+     *     since_id   - Only tweets more recent the indicated tweet id
+     *     max_id     - Only tweets older then the indeicated tweet id
+     *     count      - Only return this many tweets (twitter limit = 200)
+     *     page       - The page number to return (note there are pagination limits)
+     *   </pre>
+     *
+     * @return string
+     */
+    public function retweetsOfMe($params = array())
+    {
+        $url = $this->_endpoint . 'retweets_of_me.' . $this->_format;
+        return $this->_twitter->request->get($url, $params);
+    }
+
+    /**
+     * Retweets a tweet. Requires the id parameter of the tweet you are
+     * retweeting. Request must be a POST or PUT.
+     * Returns the original tweet with retweet details embedded.
+     *
+     * @params string id  The id for the tweet that is being retweeted.
+     */
+    public function retweet($id)
+    {
+        $url = $this->_endpoint . 'retweet.' . $this->_format;
+        $params = array('id' => $id);
+
+        return $this->_twitter->request->post($url, $params);
+    }
+
+    /**
      * Obtain the last 20 tweets from the public timeline. This is cached every
      * 60 seconds on Twitter's servers so we should eventually ensure this is
      * only actually requested every 60 seconds or greater.