-
Notifications
You must be signed in to change notification settings - Fork 69
/
tokenrequest.php
45 lines (37 loc) · 1.05 KB
/
tokenrequest.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
<?php
require_once("../src/FoursquareApi.php");
// This file is intended to be used as your redirect_uri for the client on Foursquare
// Set your client key and secret
$client_key = "<your client key>";
$client_secret = "<your client secret>";
$redirect_uri = "<your redirect uri>";
// Load the Foursquare API library
$foursquare = new FoursquareApi($client_key,$client_secret);
// If the link has been clicked, and we have a supplied code, use it to request a token
if(array_key_exists("code",$_GET)){
$token = $foursquare->GetToken($_GET['code'],$redirect_uri);
}
?>
<!doctype html>
<html>
<head>
<title>PHP-Foursquare :: Token Request Example</title>
</head>
<body>
<h1>Token Request Example</h1>
<p>
<?php
// If we have not received a token, display the link for Foursquare webauth
if(!isset($token)){
echo "<a href='".$foursquare->AuthenticationLink($redirect_uri)."'>Connect to this app via Foursquare</a>";
// Otherwise display the token
}else{
echo "Your auth token: $token";
}
?>
</p>
<hr />
<?php
?>
</body>
</html>