-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
108 lines (81 loc) · 3.01 KB
/
index.php
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
require_once 'inc/config.inc.php';
// Catches realtime updates from Instagram
if ($_SERVER['REQUEST_METHOD']==='POST') {
// Instantiates Pusher PHP API
require 'lib/Pusher.php';
// Retrieves the POST data from Instagram
$tweets = json_decode($_POST['updates'], true);
// If one or more photos has been posted, notify all clients
if (is_array($tweets) && ($length=count($tweets))>0) {
$pusher = new Pusher($pusher_key, $pusher_secret, $pusher_app_id);
$pusher->trigger(
'tweets',
'new-tweet',
array(
'newcount' => $length,
'tweets' => $_POST['updates']
)
);
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/bootstrap-responsive.css" />
<link rel="stylesheet" href="css/master.css" />
<link rel="shortcut icon" href="/favicon.ico" />
<title>Realtime Twitter Puller — Setup at Future Insights Live</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Domain.com</a>
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
</ul>
</div>
</div>
</div>
<div style="clear:both;"></div>
<div class="container mainblock">
<header>
<h1>Live Tweets</h1>
</header>
<article>
<ul id="tweets">
<li class="loading">Loading…</li>
</ul><!--/#photos-->
</article>
</div>
<footer>
<p>Brought to you by your truly, <a href="http://twitter.com/madden_joe" target="_blank">Joe</a> and <a href="http://twitter.com/sirmixaloud" target="_blank">Mirsad</a>.</p>
</footer>
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="//js.pusher.com/2.0/pusher.min.js"></script>
<script>
// Enables pusher logging - don't include this in production
Pusher.log = function(message) {
if (window.console && window.console.log) window.console.log(message);
};
// Flash fallback logging - don't include this in production
WEB_SOCKET_DEBUG = true;
// Initializes Pusher (done inline to use PHP for config variables)
var pusher = new Pusher('<?=$pusher_key?>'),
channel = pusher.subscribe('tweets'),
tag = '<?=$tag?>'; // For PHP-powered tag selection
</script>
<script src="js/twitter.js"></script>
</body>
</html>