-
Notifications
You must be signed in to change notification settings - Fork 3
/
facebook.html
76 lines (65 loc) · 2.73 KB
/
facebook.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<.html
$facebookName = "photoKandy-Studios";
$facebookUserID = "87979941601";
$facebookItemCount = 25;
$facebookAvatar = 'http://profile.ak.fbcdn.net/hprofile-ak-snc4/41475_1362462100_2106_q.jpg';
?>
<div class="content">
<img class="imgLeft" src='<?= $facebookAvatar ?>' />
<h1>Recent Facebook Posts</h1>
<p>Here are some of our most recent posts on facebook. If you are on facebook as well, you're welcome to <a href="#">Like Us</a>.</p>
<div class="listGroup">
<.html
include ('./script/facebook.html');
function time_since($original) {
// array of time period chunks
$chunks = array(
array(60 * 60 * 24 * 365 , 'year'),
array(60 * 60 * 24 * 30 , 'month'),
array(60 * 60 * 24 * 7, 'week'),
array(60 * 60 * 24 , 'day'),
array(60 * 60 , 'hour'),
array(60 , 'minute'),
);
$today = time(); /* Current unix time */
$since = $today - $original;
// $j saves performing the count function each time around the loop
for ($i = 0, $j = count($chunks); $i < $j; $i++) {
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
// finding the biggest chunk (if the chunk fits, break)
if (($count = floor($since / $seconds)) != 0) {
// DEBUG print "<!-- It's $name -->\n";
break;
}
}
$print = ($count == 1) ? '1 '.$name : "$count {$name}s";
return $print;
}
$mySM = getfacebookItems( 'http://graph.facebook.com/' . $facebookUserID . '/feed');
foreach ($mySM as $item)
{
// echo strtotime ($item["created_time"]);
// echo "<br>". $item["created_time"];
$i=0;
if ( $item["message"] != "" && $i < $facebookItemCount)
{
$i++;
$picture = $item["picture"] ? $item["picture"] : $item["icon"];
$height = $item["picture"] ? 'height:4em; overflow: hidden' : 'height:2em; overflow: hidden';
$link = $item["link"] ? $item["link"] : "#";
?>
<a href="<?=$link?>" target="_blank" class="listItem <?= $item["link"] ? "arrow" : "" ?>" style="<?=$height?>">
<?= $item["picture"] ? '<img border=0 src="' . $item["picture"] . '" />' : ($item["icon"] ? '<img border=0 style="width:64px" src="' . $picture . '" />' : "") ?>
<?= $item["message"] ?>
<span class="minor floatRight">(<?= time_since (strtotime( $item["created_time"] ) ) ?> ago)</span>
<?= $item["description"] ?>
</a>
<.html
}
}
?>
</div>
<p style="text-align: right;"><a href="http://www.facebook.com/pages/<?=$facebookName?>/<?=$facebookUserID?>">more...</a></p>
<br><br><br>
</div>