This repository has been archived by the owner on Dec 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
simpleTest.php
74 lines (63 loc) · 2.47 KB
/
simpleTest.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
<?php
ob_start();
require_once 'EpiCurl.php';
require_once 'EpiFoursquare.php';
$clientId = 'a40b1aece83e8d94a08fff1e94f87c2f04af2881a';
$clientSecret = 'e83c621567e6c430848db6dc5dde94b9';
$code = 'BFVH1JK5404ZUCI4GUTHGPWO3BUIUTEG3V3TKQ0IHVRVGVHS';
$accessToken = 'DT32251AY1ED34V5ADCTNURTGSNHWXCNTOMTQM5ANJLBLO2O';
$redirectUri = 'http://www.jaisenmathai.com/foursquare-async/simpleTest.php';
$userId = '5763863';
$fsObj = new EpiFoursquare($clientId, $clientSecret, $accessToken);
$fsObjUnAuth = new EpiFoursquare($clientId, $clientSecret);
?>
<script type="text/javascript">
function viewSource() {
document.getElementById("source").style.display = "block";
}
</script>
<h1>Simple test to make sure everything works ok</h1>
<h2><a href="javascript:void(0);" onclick="viewSource();">View the source of this file</a></h2>
<div id="source" style="display:none; padding:5px; border: dotted 1px #bbb; background-color:#ddd;">
<?php highlight_file(__FILE__); ?>
</div>
<hr>
<h2>Test an unauthenticated call to search for a venue</h2>
<?php $venue = $fsObjUnAuth->get('/venues/search', array('ll' => '40.7,-74')); ?>
<pre><?php var_dump($venue->response->groups[0]->items[0]); ?></pre>
<hr>
<?php if(!isset($_GET['code']) && !isset($_COOKIE['access_token'])) { ?>
<h2>Generate the authorization link</h2>
<?php $authorizeUrl = $fsObjUnAuth->getAuthorizeUrl($redirectUri); ?>
<a href="<?php echo $authorizeUrl; ?>"><?php echo $authorizeUrl; ?></a>
<?php } else { ?>
<h2>Display your own badges</h2>
<?php
if(!isset($_COOKIE['access_token'])) {
$token = $fsObjUnAuth->getAccessToken($_GET['code'], $redirectUri);
setcookie('access_token', $token->access_token);
$_COOKIE['access_token'] = $token->access_token;
}
$fsObjUnAuth->setAccessToken($_COOKIE['access_token']);
$badges = $fsObjUnAuth->get('/users/self/badges');
// Process the returned object and display the badge images
if (is_object($badges->response)) {
foreach ($badges->response->badges as $badge) {
echo "<img src=\"".$badge->image->prefix.$badge->image->sizes->{1}.$badge->image->name."\" title=\"".$badge->name."\" />";
}
}
?>
<div style="height: 400px; overflow: auto; width: 100%; border: 2px solid #ccc;">
<pre><?php var_dump($badges->response); ?></pre>
</div>
<?php } ?>
<hr>
<h2>Get a test user's checkins</h2>
<?php
$creds = $fsObj->get("/users/{$userId}/checkins");
?>
<div style="height: 400px; overflow: auto; width: 100%; border: 2px solid #ccc;">
<pre>
<?php var_dump($creds->response); ?>
</pre>
</div>