Skip to content

Instantly share code, notes, and snippets.

@birarda
Created May 2, 2012 18:25
Show Gist options
  • Save birarda/2578950 to your computer and use it in GitHub Desktop.
Save birarda/2578950 to your computer and use it in GitHub Desktop.
getNearestVenuesAndUsersWithCheckinsDuringInterval
function getNearestVenuesAndUsersWithCheckinsDuringInterval() {
// verify the sw_lat, sw_lng, ne_lat, and nw_lng parameters
if (verifyRequestParameter('user_lat', -90, 90) &&
verifyRequestParameter('user_lng', -180, 180) ) {
// see if we have a checked_in_since parameter, defaults to 7 if we don't
// if the user passes a negative number just let it get set to default
$checked_in_since = verifyRequestParameter('checked_in_since', 0, null, false) ?
$_REQUEST['checked_in_since'] : NULL;
// see if we have a limit parameter, defaults to 25 if we don't
// if the request has a negative parameter or more than 100 just let it get set to default
$limit = verifyRequestParameter('limit', 0, 100, false) ?
$_REQUEST['limit'] : NULL;
// grab the (limit) closest venues
$venue = new Venue();
$venues = $venue->getNearestActiveVenues(
$_REQUEST['user_lat'],
$_REQUEST['user_lng'],
$checked_in_since,
$limit
);
response(json_encode(array(
'error' => false,
'payload' => $venues
)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment