Skip to content

Instantly share code, notes, and snippets.

@azcoov
Last active June 6, 2023 20:22
Show Gist options
  • Save azcoov/7834161 to your computer and use it in GitHub Desktop.
Save azcoov/7834161 to your computer and use it in GitHub Desktop.
Example of calling the Nearby Now Content Display API with PHP. View the "Content Display API for Site Integration" page in the knowledge base for more examples.
<?php
//Base endpoint for all API calls
$endpoint = "https://api.sidebox.com/plugin";
//The resouce is the API Endpoint you'll be making a web request to
$resource = "/heatmap";
//$resource = "/nationwideserviceareareviewcombo";
//$resource = "/testimonials";
//$resource = "/photogallery";
//$resource = "/googlereviews";
//$resource = "/faq";
//required API param
$token = "get the Storefront API Token from the Nearby Now admin site";
//optional API params
$agent = urlencode($_SERVER['HTTP_USER_AGENT']);
$state = ""; // The abbreviated state. For example, Arizona should be "AZ"
$city = urlencode("");
$showMap = "";
$showFavorites = "";
$start = "";
$count = "";
$zoom = "";
$reviewCityUrl = "";
$mapSize = "";
$mapScrollWheel = "";
$fbLike = "";
$fbComment = "";
//Optinal params for the heatmap resource
$techEmail = urlencode("");
$reviewStart = "";
$checkinStart = "";
$reviewCount = "";
$checkinCount = "";
//View the "Content Display API for Site Integration" page in the knowledge base for a full list of all available params
//Optinal params for the Regional & Nation-wide Combination (beta)
$lat = "";
$long = "";
$reviewpinmax = "";
$cluster = "";
//Required params for the audio testimonials
$playlist = urlencode("");
//Optinal params for the Nearby Service Area Seview Combo resource
$showTranscription = "";
$referrer = $_SERVER['HTTP_REFERER'];
$hostUrl = "http" . (($_SERVER['SERVER_PORT'] == 443) ? "s://" : "://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
?>
<?php
// /nearbyreviews example params
$query = "?storefronttoken=$token&state=$state&city=$city&zoomlevel=$zoom&start=$start&count=$count&showmap=$showMap&mapsize=$mapSize&mapscrollwheel=$mapScrollWheel&fblike=$fbLike&fbcomment=$fbComment&showfavorites=$showFavorites&agent=$agent&referrer=$referrer&hosturl=$hostUrl";
// /nearbyservicearea example params
//$query = "?storefronttoken=$token&state=$state&city=$city&zoomlevel=$zoom&start=$start&count=$count&showmap=$showMap&mapsize=$mapSize&mapscrollwheel=$mapScrollWheel&fblike=$fbLike&fbcomment=$fbComment&showfavorites=$showFavorites&agent=$agent";
// /nearbyserviceareareviewcombo example params
//$query = "?storefronttoken=$token&state=$state&city=$city&zoomlevel=$zoom&reviewcityurl=$reviewCityUrl&reviewstart=$reviewStart&checkinstart=$checkinStart&reviewcount=$reviewCount&checkincount=$checkinCount&showmap=$showMap&mapsize=$mapSize&mapscrollwheel=$mapScrollWheel&fblike=$fbLike&fbcomment=$fbComment&showfavorites=$showFavorites&agent=$agent";
// /nationwideserviceareareviewcombo example params
//$query = "?storefronttoken=$token&state=$state&zoomlevel=$zoom&mapsize=$mapSize&lat=$lat&long=$long&reviewpinmax=$reviewpinmax&cluster=$cluster&agent=$agent";
// /photogallery example params
//$query = "?storefronttoken=$token&start=$start&count=$count&agent=$agent";
// /testimonials example params
//$query = "?storefronttoken=$token&start=$start&count=$count&playlist=$playlist&showTranscription=$showTranscription&agent=$agent";
$url = "$endpoint$resource$query";
$response = file_get_contents($url);
echo $response;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment