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; }
public function testLanguageSupport() { $foursquare = new FoursquareAPI(CLIENT_ID, CLIENT_SECRET, '', 'v2', 'fr'); $categories = json_decode($foursquare->GetPublic('venues/categories')); foreach ($categories->response->categories as $category) { if ($category->id == '4d4b7104d754a06370d81259') { $this->assertEquals($category->name, 'Culture et loisirs', "Locale failed or \"{$category->name}\" is a new translation"); $run = true; break; } } $this->assertEquals($run, true, 'Test category no longer exists in fr locale, update test.'); // Ensure we get a success response $this->assertLessThan(400, $venues->meta->code, $venues->meta->errorDetail); }
// Upload the image to EyeEm $filename = $eyeem->uploadPhoto($targetname); // initialize the EyeEm Photo object params $eye_params = array('filename' => $filename, 'title' => stripslashes(mb_ereg_replace('@', '', $_REQUEST['title'])), 'timestamp' => !empty($_REQUEST['created']) ? $_REQUEST['created'] : time()); // Save original Instagram photo ID if (!empty($instagram_id)) { $eye_params['instagram_id'] = $instagram_id; } // Geolocate through FourSquare if (!empty($_REQUEST['loc_lat']) && !empty($_REQUEST['loc_lon']) && !empty($_REQUEST['loc_name'])) { $lat = $_REQUEST['loc_lat']; $lon = $_REQUEST['loc_lon']; $location = $_REQUEST['loc_name']; $fs_params = array('ll' => $lat . ',' . $lon); // Perform a request to a public resource $response = $foursquare->GetPublic('venues/search', $fs_params); $venues = json_decode($response); $igers_name = mb_convert_case($location, MB_CASE_LOWER, 'UTF-8'); $venueId = null; // Let's try to find a matching location name near given latitude and longitude // Trying to match Instagram location name and FourSquare venue Name foreach ($venues->response->venues as $venue) { $foursquare_name = mb_convert_case($venue->name, MB_CASE_LOWER, 'UTF-8'); if ($foursquare_name == $igers_name) { // YiPPIE KI-YAY! We found a matching location name!!! $venueId = $venue->id; break; } } // If we found a venue let's include it in the EyeEm Photo object params! if (!empty($venueId)) {
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> <?php foreach ($group->items as $venue) { ?> <li> <?php echo $venue->name;
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 } }