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