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
 $fname = $row['fname'];
 //store first name
 $lname = $row['lname'];
 //store last name
 $token = $row['token'];
 //store auth token
 $name = "{$fname} {$lname}";
 $name = trim($name);
 $twitter = $row['twitter'];
 //store twitter
 $twitter = "<a href='http://twitter.com/{$twitter}' target='_blank'>";
 //create twitter link
 //retrieve foursquare info
 $foursquare = new FoursquareAPI($client_key, $client_secret);
 $foursquare->SetAccessToken($token);
 $response = $foursquare->GetPrivate("users/self/checkins");
 $loc = json_decode($response);
 $time = $loc->response->checkins->items[0]->createdAt;
 //retrieve time
 $time = date('F, jS', $time);
 //convert from unix time
 $loc = $loc->response->checkins->items[0]->venue->location;
 //retrieve location
 $currentcity = $loc->city;
 //city
 $currentstate = $loc->state;
 //state
 $lat = $loc->lat;
 //latitude
 $long = $loc->lng;
 //longitude
?>
</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 = array("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 
foreach ($users->response->results as $user) {
    ?>
			<li>
				<?php 
    if (property_exists($user, "firstName")) {