Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
profile.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 Profile class for the Joomla Platform.
14  *
15  * @package Joomla.Platform
16  * @subpackage Twitter
17  * @since 12.3
18  */
20 {
21  /**
22  * Method to et values that users are able to set under the "Account" tab of their settings page.
23  *
24  * @param string $name Full name associated with the profile. Maximum of 20 characters.
25  * @param string $url URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.
26  * @param string $location The city or country describing where the user of the account is located. The contents are not normalized
27  * or geocoded in any way. Maximum of 30 characters.
28  * @param string $description A description of the user owning the account. Maximum of 160 characters.
29  * @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
30  * variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
31  * @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
32  *
33  * @return array The decoded JSON response
34  *
35  * @since 12.3
36  */
37  public function updateProfile($name = null, $url = null, $location = null, $description = null, $entities = null, $skip_status = null)
38  {
39  // Check the rate limit for remaining hits
40  $this->checkRateLimit('account', 'update_profile');
41 
42  $data = array();
43 
44  // Check if name is specified.
45  if ($name)
46  {
47  $data['name'] = $name;
48  }
49 
50  // Check if url is specified.
51  if ($url)
52  {
53  $data['url'] = $url;
54  }
55 
56  // Check if location is specified.
57  if ($location)
58  {
59  $data['location'] = $location;
60  }
61 
62  // Check if description is specified.
63  if ($description)
64  {
65  $data['description'] = $description;
66  }
67 
68  // Check if entities is specified.
69  if (!is_null($entities))
70  {
71  $data['include_entities'] = $entities;
72  }
73 
74  // Check if skip_status is specified.
75  if (!is_null($skip_status))
76  {
77  $data['skip_status'] = $skip_status;
78  }
79 
80  // Set the API path
81  $path = '/account/update_profile.json';
82 
83  // Send the request.
84  return $this->sendRequest($path, 'POST', $data);
85  }
86 
87  /**
88  * Method to update the authenticating user's profile background image. This method can also be used to enable or disable the profile
89  * background image.
90  *
91  * @param string $image The background image for the profile.
92  * @param boolean $tile Whether or not to tile the background image.
93  * @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
94  * variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
95  * @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
96  * @param boolean $use Determines whether to display the profile background image or not.
97  *
98  * @return array The decoded JSON response
99  *
100  * @since 12.3
101  */
102  public function updateProfileBackgroundImage($image = null, $tile = false, $entities = null, $skip_status = null, $use = false)
103  {
104  // Check the rate limit for remaining hits
105  $this->checkRateLimit('account', 'update_profile_background_image');
106 
107  $data = array();
108 
109  // Check if image is specified.
110  if ($image)
111  {
112  $data['image'] = "@{$image}";
113  }
114 
115  // Check if url is true.
116  if ($tile)
117  {
118  $data['tile'] = $tile;
119  }
120 
121  // Check if entities is specified.
122  if (!is_null($entities))
123  {
124  $data['include_entities'] = $entities;
125  }
126 
127  // Check if skip_status is specified.
128  if (!is_null($skip_status))
129  {
130  $data['skip_status'] = $skip_status;
131  }
132 
133  // Check if use is true.
134  if ($use)
135  {
136  $data['use'] = $use;
137  }
138 
139  // Set the API path
140  $path = '/account/update_profile_background_image.json';
141 
142  $header = array('Content-Type' => 'multipart/form-data', 'Expect' => '');
143 
144  // Send the request.
145  return $this->sendRequest($path, 'POST', $data, $header);
146  }
147 
148  /**
149  * Method to update the authenticating user's profile image.
150  *
151  * @param string $image The background image for the profile.
152  * @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
153  * variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
154  * @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
155  *
156  * @return array The decoded JSON response
157  *
158  * @since 12.3
159  */
160  public function updateProfileImage($image = null, $entities = null, $skip_status = null)
161  {
162  // Check the rate limit for remaining hits
163  $this->checkRateLimit('account', 'update_profile_image');
164 
165  $data = array();
166 
167  // Check if image is specified.
168  if ($image)
169  {
170  $data['image'] = "@{$image}";
171  }
172 
173  // Check if entities is specified.
174  if (!is_null($entities))
175  {
176  $data['include_entities'] = $entities;
177  }
178 
179  // Check if skip_status is specified.
180  if (!is_null($skip_status))
181  {
182  $data['skip_status'] = $skip_status;
183  }
184 
185  // Set the API path
186  $path = '/account/update_profile_image.json';
187 
188  $header = array('Content-Type' => 'multipart/form-data', 'Expect' => '');
189 
190  // Send the request.
191  return $this->sendRequest($path, 'POST', $data, $header);
192  }
193 
194  /**
195  * Method to set one or more hex values that control the color scheme of the authenticating user's profile page on twitter.com.
196  *
197  * @param string $background Profile background color.
198  * @param string $link Profile link color.
199  * @param string $sidebar_border Profile sidebar's border color.
200  * @param string $sidebar_fill Profile sidebar's fill color.
201  * @param string $text Profile text color.
202  * @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
203  * variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
204  * @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
205  *
206  * @return array The decoded JSON response
207  *
208  * @since 12.3
209  */
210  public function updateProfileColors($background = null, $link = null, $sidebar_border = null, $sidebar_fill = null, $text = null,
211  $entities = null, $skip_status = null)
212  {
213  // Check the rate limit for remaining hits
214  $this->checkRateLimit('account', 'update_profile_colors');
215 
216  $data = array();
217 
218  // Check if background is specified.
219  if ($background)
220  {
221  $data['profile_background_color'] = $background;
222  }
223 
224  // Check if link is specified.
225  if ($link)
226  {
227  $data['profile_link_color'] = $link;
228  }
229 
230  // Check if sidebar_border is specified.
231  if ($sidebar_border)
232  {
233  $data['profile_sidebar_border_color'] = $sidebar_border;
234  }
235 
236  // Check if sidebar_fill is specified.
237  if ($sidebar_fill)
238  {
239  $data['profile_sidebar_fill_color'] = $sidebar_fill;
240  }
241 
242  // Check if text is specified.
243  if ($text)
244  {
245  $data['profile_text_color'] = $text;
246  }
247 
248  // Check if entities is specified.
249  if (!is_null($entities))
250  {
251  $data['include_entities'] = $entities;
252  }
253 
254  // Check if skip_status is true.
255  if (!is_null($skip_status))
256  {
257  $data['skip_status'] = $skip_status;
258  }
259 
260  // Set the API path
261  $path = '/account/update_profile_colors.json';
262 
263  // Send the request.
264  return $this->sendRequest($path, 'POST', $data);
265  }
266 
267  /**
268  * Method to get the settings (including current trend, geo and sleep time information) for the authenticating user.
269  *
270  * @return array The decoded JSON response
271  *
272  * @since 12.3
273  */
274  public function getSettings()
275  {
276  // Check the rate limit for remaining hits
277  $this->checkRateLimit('account', 'settings');
278 
279  // Set the API path
280  $path = '/account/settings.json';
281 
282  // Send the request.
283  return $this->sendRequest($path);
284  }
285 
286  /**
287  * Method to update the authenticating user's settings.
288  *
289  * @param integer $location The Yahoo! Where On Earth ID to use as the user's default trend location.
290  * @param boolean $sleep_time When set to true, t or 1, will enable sleep time for the user.
291  * @param integer $start_sleep The hour that sleep time should begin if it is enabled.
292  * @param integer $end_sleep The hour that sleep time should end if it is enabled.
293  * @param string $time_zone The timezone dates and times should be displayed in for the user. The timezone must be one of the
294  * Rails TimeZone names.
295  * @param string $lang The language which Twitter should render in for this user.
296  *
297  * @return array The decoded JSON response
298  *
299  * @since 12.3
300  */
301  public function updateSettings($location = null, $sleep_time = false, $start_sleep = null, $end_sleep = null,
302  $time_zone = null, $lang = null)
303  {
304  $data = array();
305 
306  // Check if location is specified.
307  if ($location)
308  {
309  $data['trend_location_woeid '] = $location;
310  }
311 
312  // Check if sleep_time is true.
313  if ($sleep_time)
314  {
315  $data['sleep_time_enabled'] = $sleep_time;
316  }
317 
318  // Check if start_sleep is specified.
319  if ($start_sleep)
320  {
321  $data['start_sleep_time'] = $start_sleep;
322  }
323 
324  // Check if end_sleep is specified.
325  if ($end_sleep)
326  {
327  $data['end_sleep_time'] = $end_sleep;
328  }
329 
330  // Check if time_zone is specified.
331  if ($time_zone)
332  {
333  $data['time_zone'] = $time_zone;
334  }
335 
336  // Check if lang is specified.
337  if ($lang)
338  {
339  $data['lang'] = $lang;
340  }
341 
342  // Set the API path
343  $path = '/account/settings.json';
344 
345  // Send the request.
346  return $this->sendRequest($path, 'POST', $data);
347  }
348 }