OSDN Git Service

embr
[embrj/master.git] / ajax / updateTrends.php
1 <?php
2         if(!isset($_SESSION)){
3                 session_start();
4         }
5         include ('../lib/twitese.php');
6         $t = getTwitter();
7         if (isset($_COOKIE['woeid'])) {
8                 $woeid = getEncryptCookie('woeid');
9         } else {
10                 $tr = $t->trends_closest($_GET['lat'], $_GET['long']);
11                 if (isset($tr->woeid)) {
12                         $woeid = $tr[0]->woeid;
13                 } else {
14                         $woeid = 1;
15                 }
16                 setEncryptCookie('woeid', $woeid, $_SERVER['REQUEST_TIME'] + 3600*24);
17         }
18         $tr = $t->trends_place($woeid);
19         $trends = $tr[0]->trends;
20         
21         if (count($trends) == 0) {
22                 echo "empty";
23         }else{
24                 $html = '';
25                 foreach ($trends as $trend) {
26                         $li = '
27                                 <li>
28                                 <a href="search.php?q='.$trend->query.'">'.$trend->name.'</a>
29                                 </li>
30                                 ';
31                         $html .= $li;
32                 }
33                 echo $html;
34         }
35 ?>