Source for file favorites.php

Documentation is available at favorites.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Twitter
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die();
  11.  
  12. /**
  13.  * Twitter API Favorites class for the Joomla Platform.
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Twitter
  17.  * @since       12.3
  18.  */
  19. {
  20.     /**
  21.      * Method to get the most recent favorite statuses for the authenticating or specified user.
  22.      *
  23.      * @param   mixed    $user      Either an integer containing the user ID or a string containing the screen name.
  24.      * @param   integer  $count     Specifies the number of tweets to try and retrieve, up to a maximum of 200.  Retweets are always included
  25.      *                               in the count, so it is always suggested to set $include_rts to true
  26.      * @param   integer  $since_id  Returns results with an ID greater than (that is, more recent than) the specified ID.
  27.      * @param   integer  $max_id    Returns results with an ID less than (that is, older than) the specified ID.
  28.      * @param   boolean  $entities  When set to true,  each tweet will include a node called "entities,". This node offers a variety
  29.      *                                  of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
  30.      *
  31.      * @return  array  The decoded JSON response
  32.      *
  33.      * @since   12.3
  34.      */
  35.     public function getFavorites($user null$count 20$since_id 0$max_id 0$entities null)
  36.     {
  37.         // Check the rate limit for remaining hits
  38.         $this->checkRateLimit('favorites''list');
  39.  
  40.         // Set the API path.
  41.         $path '/favorites/list.json';
  42.  
  43.         // Determine which type of data was passed for $user
  44.         if (is_numeric($user))
  45.         {
  46.             $data['user_id'$user;
  47.         }
  48.         elseif (is_string($user))
  49.         {
  50.             $data['screen_name'$user;
  51.         }
  52.  
  53.         // Set the count string
  54.         $data['count'$count;
  55.  
  56.         // Check if since_id is specified.
  57.         if ($since_id 0)
  58.         {
  59.             $data['since_id'$since_id;
  60.         }
  61.  
  62.         // Check if max_id is specified.
  63.         if ($max_id 0)
  64.         {
  65.             $data['max_id'$max_id;
  66.         }
  67.  
  68.         // Check if entities is specified.
  69.         if (!is_null($entities))
  70.         {
  71.             $data['include_entities'$entities;
  72.         }
  73.  
  74.         // Send the request.
  75.         return $this->sendRequest($path'GET'$data);
  76.     }
  77.  
  78.     /**
  79.      * Method to favorite the status specified in the ID parameter as the authenticating user
  80.      *
  81.      * @param   integer  $id        The numerical ID of the desired status.
  82.      * @param   boolean  $entities  When set to true,  each tweet will include a node called "entities,". This node offers a variety
  83.      *                                  of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
  84.      *
  85.      * @return  array  The decoded JSON response
  86.      *
  87.      * @since   12.3
  88.      */
  89.     public function createFavorites($id$entities null)
  90.     {
  91.         // Set the API path.
  92.         $path '/favorites/create.json';
  93.  
  94.         $data['id'$id;
  95.  
  96.         // Check if entities is specified.
  97.         if (!is_null($entities))
  98.         {
  99.             $data['include_entities'$entities;
  100.         }
  101.  
  102.         // Send the request.
  103.         return $this->sendRequest($path'POST'$data);
  104.     }
  105.  
  106.     /**
  107.      * Method to un-favorites the status specified in the ID parameter as the authenticating user.
  108.      *
  109.      * @param   integer  $id        The numerical ID of the desired status.
  110.      * @param   boolean  $entities  When set to true,  each tweet will include a node called "entities,". This node offers a variety
  111.      *                                  of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
  112.      *
  113.      * @return  array  The decoded JSON response
  114.      *
  115.      * @since   12.3
  116.      */
  117.     public function deleteFavorites($id$entities null)
  118.     {
  119.         // Set the API path.
  120.         $path '/favorites/destroy.json';
  121.  
  122.         $data['id'$id;
  123.  
  124.         // Check if entities is specified.
  125.         if (!is_null($entities))
  126.         {
  127.             $data['include_entities'$entities;
  128.         }
  129.  
  130.         // Send the request.
  131.         return $this->sendRequest($path'POST'$data);
  132.     }
  133. }

Documentation generated on Tue, 19 Nov 2013 15:02:50 +0100 by phpDocumentor 1.4.3