OSDN Git Service

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