This repository has been archived by the owner on May 3, 2018. It is now read-only.
/
index.php
176 lines (161 loc) · 5.11 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
include(__DIR__ . '/../includes/__init__.php');
echo output_header();
$signed_request = parse_signed_request($_REQUEST['signed_request'], $config['AppSecret']);
$page_name = json_decode(curl_call('https://graph.facebook.com/'.$signed_request['page']['id']), true);
$user_name = json_decode(curl_call('https://graph.facebook.com/'.$signed_request['user_id']), true);
// Does the viewing user like the page?
if ($signed_request['page']['liked']) {
$like_status = 'Yes';
} else {
$like_status = 'No';
}
// is the viewing user an admin?
if ($signed_request['page']['admin']) {
$admin_status = 'Yes';
} else {
$admin_status = 'No';
}
// what age is the viewing user
if ($signed_request['user']['age']['min'] >= 21) {
$age_range = 'User is over 21';
} else if ($signed_request['user']['age']['min'] <= 0 && $signed_request['user']['age']['min'] <= 12) {
$age_range = 'User is not logged in, assume under 12';
} else if ($signed_request['user']['age']['min'] <= 12 && $signed_request['user']['age']['min'] <= 18) {
$age_range = 'User is older than 12, but under 18';
} else if ($signed_request['user']['age']['min'] <= 18 && $signed_request['user']['age']['min'] <= 21) {
$age_range = 'User is over 18, but under 21';
} else {
$age_range = 'Unsure of age';
}
if ($signed_request['app_data']) {
$app_data = htmlspecialchars($signed_request['app_data']);
} else {
$app_data = 'No app_data supplied';
}
if ($signed_request['oauth_token']) {
$token = $signed_request['oauth_token'];
} else {
$token = 'No token supplied';
}
if ($signed_request['expires']){
$token_expiry = $signed_request['expires'];
} else {
$token_expiry = 'No expiry time provided';
}
if ($signed_request['user_id']){
$user_id = $signed_request['user_id'];
} else {
$user_id = 'No user id provided';
}
?>
<body>
<script>
<!-- TODO - Make this more dynamic -->
if(self == top) {
window.location.replace("http://www.facebook.com/colmstestpage/app_120999667956026");
}
</script>
<h1 class="center"><?php echo $config['AppName']; ?></h1>
<div id="signed_request_container" class="page-tab container">
<?php
if (!$_REQUEST['signed_request']) {
$warning = '<div class="page-tab span-9">';
$warning .= '<p class="alert box"> <span class="bold"> ERROR: </span> No signed_request </p>';
$warning .= '</div>';
echo $warning;
}
?>
<div class="page-tab span-4">
<h3> The signed_request </h3>
<table>
<tr>
<td>Encryption</td>
<td><?php echo $signed_request['algorithm']; ?></td>
</tr>
<tr>
<td>Issue Time</td>
<td><?php echo $signed_request['issued_at'];?></td>
</tr>
<tr>
<td>App Data</td>
<td><?php echo $app_data; ?></td>
</tr>
</table>
</div>
<div class="page-tab span-5 last">
<h3> The Page you're on </h3>
<table>
<tr>
<td> FB ID </td>
<td>
<a href="<?php echo $config['graph-explorer'].$signed_request['page']['id']?>" target="_blank">
<?php echo $signed_request['page']['id'];?>
</a>
</td>
</tr>
<tr>
<td> Page Name </td>
<td> <?php echo $page_name['name']; ?> </td>
</tr>
<tr>
<td> Do you like? </td>
<td> <?php echo $like_status; ?> </td>
</tr>
<tr>
<td> Are you an admin? </td>
<td> <?php echo $admin_status; ?> </td>
</tr>
</table>
</div>
<div class="page-tab span-4">
<h3> The User </h3>
<table>
<tr>
<td>Country</td>
<td><?php echo $signed_request['user']['country'];?> </td>
</tr>
<tr>
<td>Locale</td>
<td><?php echo $signed_request['user']['locale'];?> </td>
</tr>
<tr>
<td>Age</td>
<td><?php echo $age_range; ?></td>
</tr>
</table>
</div>
<div class="page-tab span-5">
<h3> oAuth info </h3>
<table>
<tr>
<td>Token</td>
<td>
<a href="<?php echo $config['fb-debug'].$token; ?>" target="_blank">
<?php echo $token;?></a>
</td>
</tr>
<tr>
<td>Expiries</td>
<td><?php echo $token_expiry;?> </td>
</tr>
<tr>
<td>User ID</td>
<td>
<a href="<?php echo $config['graph-explorer'].$user_id; ?>" target="_blank">
<?php echo $user_id; ?></a>
<?php echo ' (' . $user_name['name'] . ')'; ?>
</td>
</tr>
</table>
</div>
<h4 class="italic"> Raw signed_request </h4>
<?php
echo('<pre>');
print_r($signed_request);
echo('</pre>');
?>
<br />
<p> This code is available on <a href="<?php echo $config['github-url'];?>" target="_blank">Github</a></p>
</div>
</body>