public function testCheckin()
 {
     $foursquare = new FoursquareApi(CLIENT_ID, CLIENT_SECRET);
     $foursquare->SetAccessToken(TOKEN);
     // Checks the acting user in at Aux Vivres in Montreal, Canada
     $response = json_decode($foursquare->GetPrivate("checkins/add", array("venueId" => "4ad4c06bf964a5207ff920e3"), $POST = true));
     $this->assertLessThan(400, $response->meta->code, $response->meta->errorDetail);
 }
示例#2
0
<?php

require_once '../vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
use FoursquareApi\FoursquareApi;
// Set your client key and secret
$client_key = "";
$client_secret = "";
// Load the Foursquare API library
if ($client_key == "" or $client_secret == "") {
    echo 'Load client key and client secret from <a href="https://developer.foursquare.com/">foursquare</a>';
    exit;
}
$foursquare = new FoursquareApi($client_key, $client_secret);
$location = array_key_exists("location", $_GET) ? $_GET['location'] : "Montreal, QC";
?>
<!doctype html>
<html>
<head>
    <title>PHP-Foursquare :: Unauthenticated Request Example</title>
    <style>
        div.venue {
            float: left;
            padding: 10px;
            background: #efefef;
            height: 90px;
            margin: 10px;
            width: 340px;
        }

        div.venue a {
            color: #000;
    <input type="text" name="name"/>
    <input type="submit" value="Search!"/>
</form>
<p>Searching for users with name similar to <?php 
echo $name;
?>
</p>
<hr/>
<?php 
// Set your client key and secret
$client_key = "<your client key>";
$client_secret = "<your client secret>";
// Set your auth token, loaded using the workflow described in tokenrequest.php
$auth_token = "<your auth token>";
// Load the Foursquare API library
$foursquare = new FoursquareApi($client_key, $client_secret);
$foursquare->SetAccessToken($auth_token);
// Prepare parameters
$params = ["name" => $name];
// Perform a request to a authenticated-only resource
$response = $foursquare->GetPrivate("users/search", $params);
$users = json_decode($response);
// NOTE:
// Foursquare only allows for 500 api requests/hr for a given client (meaning the below code would be
// a very inefficient use of your api calls on a production application). It would be a better idea in
// this scenario to have a caching layer for user details and only request the details of users that
// you have not yet seen. Alternatively, several client keys could be tried in a round-robin pattern
// to increase your allowed requests.
?>
<ul>
    <?php 
<?php

require_once '../vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
use FoursquareApi\FoursquareApi;
// 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 {