OSDN Git Service

embrj
[embrj/master.git] / favor.php
1 <?php 
2         include ('lib/twitese.php');
3         $title = "My Favorites";
4         include ('inc/header.php');
5         if (!loginStatus()) header('location: login.php');
6 ?>
7
8 <script src="js/btns.js"></script>
9
10 <div id="statuses" class="column round-left">
11
12         <?php include('inc/sentForm.php')?>
13
14 <?php 
15         $t = getTwitter();
16         $user_id = isset($_GET['user_id']) ? $_GET['user_id'] : false;
17         $since_id = isset($_GET['since_id']) ? $_GET['since_id'] : false;
18         $max_id = isset($_GET['max_id']) ? $_GET['max_id'] : false;
19
20         $statuses = $t->getFavorites($user_id, $since_id, $max_id);
21         if ($statuses === false) {
22                 header('location: error.php');exit();
23         } 
24         $empty = count($statuses) == 0 ? true : false;
25         if ($empty) {
26                 echo "<div id=\"empty\">No tweet to display.</div>";
27         } else if ($t->http_code == 429) {
28                 echo "<div id=\"empty\">API quota is used out, please wait for a moment before next refresh.</div>";
29         } else {
30                 $output = '<ol class="timeline" id="allTimeline">';
31                 include('lib/timeline_format.php');
32                 $firstid = false;
33                 $lastid = false;
34                 foreach ($statuses as $status) {
35                         if (isset($status->retweeted_status)) {
36                                 $output .= format_retweet($status);
37                         } else { 
38                                 $output .= format_timeline($status,$t->username);
39                         }
40                         if(!$firstid)
41                                 $firstid = $status->id_str;
42                         $lastid = $status->id_str;
43                 }
44                 $lastid = bcsub($lastid, "1");
45
46                 $output .= "</ol><div id=\"pagination\">";
47
48                 $output .= "<a id=\"less\" class=\"round more\" style=\"float: left;\" href=\"favor.php?since_id={$firstid}\">Back</a>";
49                 $output .= "<a id=\"more\" class=\"round more\" style=\"float: right;\" href=\"favor.php?max_id={$lastid}\">Next</a>";
50
51                 $output .= "</div>";
52
53                 echo $output;
54         }
55 ?>
56 </div>
57
58 <?php 
59         include ('inc/sidebar.php');
60         include ('inc/footer.php');
61 ?>