Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
favorites.php
Aller à la documentation de ce fichier.
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  */
20 {
21  /**
22  * Method to get the most recent favorite statuses for the authenticating or specified user.
23  *
24  * @param mixed $user Either an integer containing the user ID or a string containing the screen name.
25  * @param integer $count Specifies the number of tweets to try and retrieve, up to a maximum of 200. Retweets are always included
26  * in the count, so it is always suggested to set $include_rts to true
27  * @param integer $since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
28  * @param integer $max_id Returns results with an ID less than (that is, older than) the specified ID.
29  * @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety
30  * of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
31  *
32  * @return array The decoded JSON response
33  *
34  * @since 12.3
35  */
36  public function getFavorites($user = null, $count = 20, $since_id = 0, $max_id = 0, $entities = null)
37  {
38  // Check the rate limit for remaining hits
39  $this->checkRateLimit('favorites', 'list');
40 
41  // Set the API path.
42  $path = '/favorites/list.json';
43 
44  // Determine which type of data was passed for $user
45  if (is_numeric($user))
46  {
47  $data['user_id'] = $user;
48  }
49  elseif (is_string($user))
50  {
51  $data['screen_name'] = $user;
52  }
53 
54  // Set the count string
55  $data['count'] = $count;
56 
57  // Check if since_id is specified.
58  if ($since_id > 0)
59  {
60  $data['since_id'] = $since_id;
61  }
62 
63  // Check if max_id is specified.
64  if ($max_id > 0)
65  {
66  $data['max_id'] = $max_id;
67  }
68 
69  // Check if entities is specified.
70  if (!is_null($entities))
71  {
72  $data['include_entities'] = $entities;
73  }
74 
75  // Send the request.
76  return $this->sendRequest($path, 'GET', $data);
77  }
78 
79  /**
80  * Method to favorite the status specified in the ID parameter as the authenticating user
81  *
82  * @param integer $id The numerical ID of the desired status.
83  * @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety
84  * of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
85  *
86  * @return array The decoded JSON response
87  *
88  * @since 12.3
89  */
90  public function createFavorites($id, $entities = null)
91  {
92  // Set the API path.
93  $path = '/favorites/create.json';
94 
95  $data['id'] = $id;
96 
97  // Check if entities is specified.
98  if (!is_null($entities))
99  {
100  $data['include_entities'] = $entities;
101  }
102 
103  // Send the request.
104  return $this->sendRequest($path, 'POST', $data);
105  }
106 
107  /**
108  * Method to un-favorites the status specified in the ID parameter as the authenticating user.
109  *
110  * @param integer $id The numerical ID of the desired status.
111  * @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety
112  * of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
113  *
114  * @return array The decoded JSON response
115  *
116  * @since 12.3
117  */
118  public function deleteFavorites($id, $entities = null)
119  {
120  // Set the API path.
121  $path = '/favorites/destroy.json';
122 
123  $data['id'] = $id;
124 
125  // Check if entities is specified.
126  if (!is_null($entities))
127  {
128  $data['include_entities'] = $entities;
129  }
130 
131  // Send the request.
132  return $this->sendRequest($path, 'POST', $data);
133  }
134 }