OSDN Git Service

8e767db030ad93126a9f924022ebd2a9f1572182
[embrj/master.git] / inc / trends.php
1 <?php\r
2         include_once('../lib/twitese.php');\r
3         function getTrends($format = 'json'){\r
4                 if($format !== 'json' && $format !== 'xml'){\r
5                         return false;\r
6                 }\r
7                 $url = 'http://search.twitter.com/trends.'.$format;\r
8                 $response = objectifyJson(processCurl($url));\r
9                 return $response;\r
10         }\r
11 \r
12         function outputTrends($format = 'json'){\r
13                 $trends = getTrends($format);\r
14                 if(!isset($trends->trends)){\r
15                         return false;\r
16                 }\r
17                 $html = '';\r
18                 foreach ($trends->trends as $trend) {\r
19                         $li = '\r
20                                 <li>\r
21                                 <a href="search.php?q='.rawurlencode($trend->name).'">'.$trend->name.'</a>\r
22                                 </li>\r
23                                 ';\r
24                         $html .= $li;\r
25                 }\r
26 \r
27                 return $html;\r
28         }\r
29 ?>\r