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); }
public static function getVenueByLatLng($lat, $lng) { $foursquare = new FoursquareAPI(FOURSQUARE_CLIENT_KEY, FOURSQUARE_CLIENT_SECRET); list($lat, $lng) = array($lat, $lng); // Prepare parameters $params = array("ll" => "{$lat},{$lng}", "categoryId" => "4bf58dd8d48988d113951735", "radius" => "800"); // Perform a request to a public resource $response = $foursquare->GetPublic("venues/search", $params); return $response; }
<?php require_once "src/FoursquareAPI.class.php"; //foursquare doc //foursquare creds $client_key = "xxxxx"; //add foursquare client key $client_secret = "xxxxx"; //add foursquare client secret $redirect_uri = "xxxx"; //add 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); } //conncect to db $link = mysql_connect("xxDB HOSTxxx", "xxDB USER NAMExxx", "xxxDB Passxxx"); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("xxxDB Namexxx"); if (!$db_selected) { die('Can\'t use foo : ' . mysql_error()); } ?> <!doctype html> <html> <head> <title>Add your account</title>
<?php require_once APP_DIR . '/api/foursquare/src/FoursquareAPI.class.php'; $foursquare = new FoursquareAPI($auth_config['foursquare']['client_id'], $auth_config['foursquare']['client_secret']); function return_json($mediaList = array(), $max_id = null, $error = null) { return json_encode(array('media' => $mediaList, 'error' => $error, 'max_id' => $max_id)); } $error = null; $mediaList = array(); // Instagram userid to look for in the RegEx to parse $instagram_id $instagram_userid = !empty($_REQUEST['igers_user']) ? $_REQUEST['igers_user'] : '******'; // Original photo ID on Instagram $instagram_id = !empty($_REQUEST['igers_id']) ? $_REQUEST['igers_id'] : null; // Is this photo already on EyeEm? $isDuplicated = false; // Return empty JSON object if an access token session isnt present if (empty($_SESSION['eyeem_access_token']['access_token'])) { exit(return_json(array(), null, 'You are not authenticated in EyeEm!')); } else { $eyeem->setAccessToken($_SESSION['eyeem_access_token']['access_token']); } // Let's get the list of photos with an Instagram ID try { $igList = $eyeem->request('/experimental/instagramIds', 'GET', array(), true); $igList = $igList['instagramIds']; $canWeCheck4Duplicates = true; } catch (Exception $e) { $canWeCheck4Duplicates = false; } if ($canWeCheck4Duplicates) {
Search for venues near... <form action="" method="GET"> <input type="text" name="location" /> <input type="submit" value="Search!" /> </form> <p>Searching for venues near <?php echo $location; ?> </p> <hr /> <?php // Set your client key and secret $client_key = "<your client key>"; $client_secret = "<your client secret>"; // Load the Foursquare API library $foursquare = new FoursquareAPI($client_key, $client_secret); // Generate a latitude/longitude pair using Google Maps API list($lat, $lng) = $foursquare->GeoLocate($location); // Prepare parameters $params = array("ll" => "{$lat},{$lng}"); // Perform a request to a public resource $response = $foursquare->GetPublic("venues/search", $params); $venues = json_decode($response); foreach ($venues->response->groups as $group) { ?> <h2><?php echo $group->name; ?> </h2> <ul>
//iterate through all users while ($row = mysql_fetch_assoc($result)) { $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
<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 = 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
function draw_widget_foursquare($widget, $position = FALSE, $preview = FALSE) { if (!is_object($widget)) { return FALSE; } $CI = get_instance(); // $CI->load->library('twitteroauth'); // $CI->config->load('twitter'); $foursquare_key = $CI->config->item('foursquare_key'); $foursquare_secret = $CI->config->item('foursquare_secret'); // check if user and pass are set if (!isset($foursquare_key) || !isset($foursquare_secret) || !$foursquare_key || !$foursquare_secret) { die('ERROR: Foursquare secret and key is not defined.' . PHP_EOL); } if ($widget->widget_data == '') { $widget->widget_data = 'a:1:{i:1;a:2:{s:5:"title";s:15:"Foursquare Feed";s:7:"hashtag";s:24:"5321b871498e22c8856f46e8";}}'; } require_once APPPATH . 'widgets/foursquare/FoursquareAPI.class.php'; if ($preview) { ?> <div id="widget-<?php echo $widget->widget_type . '-' . $widget->id; ?> " class="widget widget-wrapper" data-type="<?php echo $widget->widget_type; ?> "> <div class="widget-top"> <div class="widget-title"><h4>Foursquare Feed<span class="in-widget-title"></span></h4></div> <div class="widget-action"> <span class="glyphicon glyphicon-move move-widget" title="Move"></span> <span class="glyphicon glyphicon-edit edit-widget" data-toggle="modal" data-target="#widget-<?php echo $widget->widget_type . '-' . $widget->id; ?> -modal" title="Edit"></span> <span class="glyphicon glyphicon-remove delete-widget" title="Delete"></span> </div> </div> <div class="widget-inside"> <?php } $foursquares = unserialize($widget->widget_data); //i don't what is the plan, do you plan to support multiple hashtag? //for now I assume it store in wrong way if (is_array($foursquares) && count($foursquares) > 0) { $foursquares = $foursquares[1]; //-> remove this after fix store data function ?> <div class="widget foursquare"> <div class="panel panel-default widget-testimonials-full"> <div class="panel-heading"> <h3 class="panel-title">People in your neighborhood are checking in at <?php echo $foursquares['hashtag']; ?> </h3> </div> <div class="panel-body"> <?php //$foursquare_connection = $CI->twitteroauth->create($consumer_token, $consumer_secret); $foursquare_connection = new FoursquareAPI($foursquare_key, $foursquare_secret); if ($foursquares['hashtag'] == '') { $foursquares['hashtag'] = 'KFC'; } $params = array('near' => 'Salt Lake City, UT', 'query' => $foursquares['hashtag']); $response = $foursquare_connection->GetPublic("venues/search", $params); $venues = json_decode($response); if (!isset($venues->response->venues[0])) { echo 'Business name is not found'; echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; return; } $venue_id = $venues->response->venues[0]->id; $params = array('VENUE_ID' => $venue_id); $response = $foursquare_connection->GetPublic("venues/" . $venue_id, $params); $venues = json_decode($response); // print_r($venues); //$results = $foursquare_connection->get('search/tweets', $query); $i = 0; $venue = $venues->response->venue; // foreach ($venues->response->venue as $venue): $i++; // print_r($venue); if (isset($venue->categories['0'])) { $img = $venue->categories['0']->icon->prefix . '64.png'; } else { $img = 'https://foursquare.com/img/categories/building/default_64.png'; } if ($i <= 1) { ?> <div class="panel-review pull-left"> <!-- <img src="<?php echo $img; ?> " width="64" height="64" alt="" class="foursquareicon pull-left"/> <div class="media-body"> <h4 class="media-heading"><a target="_blank" href="<?php echo $venue->canonicalUrl; ?> "><?php echo $venue->name; ?> </a></h4> --> <?php /* if(isset($venue->categories['0'])) { if(property_exists($venue->categories['0'],"name")) { echo ' <i> '.$venue->categories['0']->name.'</i><br/>'; } } if(isset($venue->location->formattedAddress)) { echo $venue->location->formattedAddress[0].'<br />'; if(isset($venue->location->formattedAddress[1]) && $venue->location->formattedAddress[1]!='United States') { echo $venue->location->formattedAddress[1].'<br />'; } if(isset($venue->location->formattedAddress[2]) && $venue->location->formattedAddress[2]!='United States') { echo $venue->location->formattedAddress[2].'<br />'; } } if(isset($venue->contact->formattedPhone)) { echo 'Phone '.$venue->contact->formattedPhone.'<br />'; } if(property_exists($venue->hereNow,"count")) { echo $venue->hereNow->count ." people currently here <br/> "; } echo '<b><i>Stats</i></b> :'.$venue->stats->usersCount." visitors, ". $venue->stats->checkinsCount." visits, ".$venue->stats->tipCount.' tips</div>'; */ // echo '</div>'; if ($venue->stats->tipCount > 0) { $tip_params = array('VENUE_ID', $venue->id, 'sort' => 'recent'); $r_tips = $foursquare_connection->GetPublic("venues/" . $venue->id . "/tips", $tip_params); $tips = json_decode($r_tips); //print_r($tips); // echo '<b>Tips</b> : <br />'; foreach ($tips->response->tips->items as $tip) { //echo '<image class="icon" src="'.$tip->user->photo->prefix.$tip->user->photo->suffix.'"/>'; //echo '<a href="">'; echo '<div class="panel-review pull-left">'; echo '<img src="' . $tip->user->photo->prefix . '64x64' . $tip->user->photo->suffix . '" class="img64 pull-left"/>'; echo '<div class="media-body">'; echo '<h4 class="media-heading">'; if (isset($tip->user->firstName)) { echo $tip->user->firstName . ' '; } if (isset($tip->user->lastName)) { echo $tip->user->lastName; } echo ' : </h4>' . $tip->text . '</div></div>'; } // if($tips->response->tips->count == '0') { // echo 'ZERO'; // } echo { // echo 'HOUSTON, WE GOT TIPS'; //} //print_r($tips->response->tips->count);die(); } ?> </div> <?php } // endforeach; } //if ( is_array($foursquares) && count($foursquares) > 0 ): ?> </div> </div> </div> <?php if ($preview) { ?> </div> <div class="widget-description">Add Foursquare Feeds</div> </div> <?php } }