Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
trends.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 Trends 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 top 10 trending topics for a specific WOEID, if trending information is available for it.
23  *
24  * @param integer $id The Yahoo! Where On Earth ID of the location to return trending information for.
25  * Global information is available by using 1 as the WOEID.
26  * @param string $exclude Setting this equal to hashtags will remove all hashtags from the trends list.
27  *
28  * @return array The decoded JSON response
29  *
30  * @since 12.3
31  */
32  public function getTrends($id, $exclude = null)
33  {
34  // Check the rate limit for remaining hits
35  $this->checkRateLimit('trends', 'place');
36 
37  // Set the API path
38  $path = '/trends/place.json';
39 
40  $data['id'] = $id;
41 
42  // Check if exclude is specified
43  if ($exclude)
44  {
45  $data['exclude'] = $exclude;
46  }
47 
48  // Send the request.
49  return $this->sendRequest($path, 'GET', $data);
50  }
51 
52  /**
53  * Method to get the locations that Twitter has trending topic information for.
54  *
55  * @return array The decoded JSON response
56  *
57  * @since 12.3
58  */
59  public function getLocations()
60  {
61  // Check the rate limit for remaining hits
62  $this->checkRateLimit('trends', 'available');
63 
64  // Set the API path
65  $path = '/trends/available.json';
66 
67  // Send the request.
68  return $this->sendRequest($path);
69  }
70 
71  /**
72  * Method to get the locations that Twitter has trending topic information for, closest to a specified location.
73  *
74  * @param float $lat The latitude to search around.
75  * @param float $long The longitude to search around.
76  *
77  * @return array The decoded JSON response
78  *
79  * @since 12.3
80  */
81  public function getClosest($lat = null, $long = null)
82  {
83  // Check the rate limit for remaining hits
84  $this->checkRateLimit('trends', 'closest');
85 
86  // Set the API path
87  $path = '/trends/closest.json';
88 
89  $data = array();
90 
91  // Check if lat is specified
92  if ($lat)
93  {
94  $data['lat'] = $lat;
95  }
96 
97  // Check if long is specified
98  if ($long)
99  {
100  $data['long'] = $long;
101  }
102 
103  // Send the request.
104  return $this->sendRequest($path, 'GET', $data);
105  }
106 }