This repository has been archived by the owner on Jan 18, 2018. It is now read-only.
/
index.php
148 lines (115 loc) · 4.75 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
include 'lib/EpiCurl.php';
include 'lib/EpiOAuth.php';
include 'lib/EpiTwitter.php';
include 'lib/secret.php';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
$oauth_token = '';
// get oauth token from session or from GET param
if(isset($_SESSION['ot']) && isset($_SESSION['ots'])) {
$oauth_token = $_SESSION['ot'];
$oauth_token_secret = $_SESSION['ots'];
$twitterObj->setToken($oauth_token, $oauth_token_secret);
} else if(isset($_GET['oauth_token'])) {
// handle oauth callback from Twitter
$twitterObj->setToken($_GET['oauth_token']);
$token = $twitterObj->getAccessToken();
$twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);
$_SESSION['ot'] = $token->oauth_token;
$_SESSION['ots'] = $token->oauth_token_secret;
$oauth_token = $_SESSION['ot'];
$oauth_token_secret = $_SESSION['ots'];
}
if($oauth_token == '')
// get authentication URL and display sign in link
{
try {
$url = $twitterObj->getAuthenticateUrl();
}catch(EpiTwitterException $e){
echo 'We caught an EpiOAuthException';
echo $e->getMessage();
}catch(Exception $e){
echo 'We caught an unexpected Exception';
echo $e->getMessage();
}
echo "<div align='right'>";
echo "<a href='$url'>Sign In</a>";
echo "</div>";
}
else
// authenticated to Twitter
{
$twitterInfo = $twitterObj->get_accountVerify_credentials();
$user['username'] = $twitterInfo->screen_name;
$user['profilepic'] = $twitterInfo->profile_image_url;
$hometimeline= $twitterObj->get_statusesHome_timeline();
$responseArray = array();
try{
foreach($hometimeline as $status) {
$responseArray[] = array('screenname' => $status->user->screen_name, 'text' => $status->text);
}
}catch(EpiTwitterException $e){
echo $e->getMessage();
}
// requires json_encode function
$json_response = json_encode($responseArray);
}
?>
<!DOCTYPE html >
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" id="iphone-viewport" content="minimum-scale=1.0, maximum-scale=1.0, width=device-width" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="stylesheet" href="spinningwheel.css" type="text/css" media="all" />
<link href='http://fonts.googleapis.com/css?family=Allan:700' rel='stylesheet' type='text/css'>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script type="text/javascript" src="strftime-min.js"></script>
<script type="text/javascript" src="spinningwheel-min.js?v=1.4"></script>
<script type="text/javascript" src="tweetalarm-alarm.js"></script>
<script type="text/javascript" src="tweetalarm-tweet.js"></script>
<script type="text/javascript" src="tweetalarm-txt2speech.js"></script>
<!--[if IE]><script type="text/javascript" src="excanvas.js"></script><![endif]-->
<script type="text/javascript" src="coolclock/coolclock.js"></script>
<script type="text/javascript" src="coolclock/moreskins.js"></script>
<script>
<?php if(isset($json_response)) {
echo "var twitter_response = ".$json_response.";";
}
?>
</script>
<title>Tweet Alarm</title>
<style type="text/css">
body { text-align:center; font-family:helvetica; background-color:#3BB9FF; }
button { font-size:16px; }
#alarm { margin:10px; background:#aaa; -webkit-border-radius:8px; padding:8px; font-size:18px; }
#tweet { margin:10px; background:#aaa; -webkit-border-radius:8px; padding:8px; font-size:18px; }
#AppName {font-size:12px;text-align:center;margin-top:-40px;font-family:Allan;color:#fff}
#signout {float:right; font-size:8px;}
#mainContainer { margin:10px; background:#fff; -webkit-border-radius:8px;height:350px; }
</style>
</head>
<p><?php
if (isset($user)) {
?>
<div style="text-align:left;">
<?php echo "<img src= '".$user['profilepic']."' width=\"20\" height=\"20\"/>" ?>
<!--<?php echo $user['username'] ?>-->
<div id="signout" style="font-size:8px;"<a href="http://twitter.com/logout">sign out</a></div>
</div>
<?php
}
?></p>
<div id="AppName"<h1>Tweet Alarm</h1>
<body onload="CoolClock.findAndCreateClocks()"><div id="mainContainer">
<div style="display:none"<p>Current Time:</p><p id="current_time"></p></div>
<canvas id="u44" class="CoolClock:simple" width="170" height="170" style="width: 170px; height: 170px; align:center; " onclick="setAlarm()"></canvas>
<!--<button onclick="setAlarm()">Set Alarm</button>-->
<p id="alarm">Alarm set to:</p>
<p id="tweet"></p>
<span id="tweetAudio"></span>
</div></body>
<div style="font-size:7px;"<p>Scroll wheel component provided by <a href="http://cubiq.org/spinning-wheel-on-webkit-for-iphone-ipod-touch/11">cubiq.org</a></p></div>
</html>