Skip to content

Instantly share code, notes, and snippets.

@azcoov
Last active October 11, 2023 21:52
Show Gist options
  • Save azcoov/7835024 to your computer and use it in GitHub Desktop.
Save azcoov/7835024 to your computer and use it in GitHub Desktop.
Example of calling the Nearby Now API with C#. View the API Integration page for more examples: http://servicepros.nearbynow.co/plugins/api-integration/
public class ApiSampleController : Controller
{
private const string api =
"https://api.sidebox.com/plugin/heatmap?storefronttoken={0}&state={1}&city={2}&zoomlevel={3}&showmap={4}&techemail={5}&mapscrollwheel={6}&agent={7}&checkincount={8}&reviewcount={9}";
private const string StorefrontToken = "get this from the Nearby Now admin site";
public ActionResult NearbyNowReviews(String State, String City)
{
var agent = Request.UserAgent;
var wc = new WebClient();
ViewBag.NearbyNowContent = wc.DownloadString(String.Format(api,
HttpUtility.UrlEncode(StorefrontToken),
HttpUtility.UrlEncode(State),
HttpUtility.UrlEncode(City),
"", // zoomlevel
"", // showmap
"", // techemail
"", // mapscrollwheel
HttpUtility.UrlEncode(agent),
20, // checkincount
20) // reviewcount
);
return View();
}
}
public class ApiSampleController : Controller
{
private const string api =
"https://api.sidebox.com/plugin/nearbyreviews?storefronttoken={0}&state={1}&city={2}&zoomlevel={3}&radius={4}&showmap={5}&techemail={6}&mapscrollwheel={7}&fblike={8}&fbcomment={9}&agent={10}&count={11}";
private const string StorefrontToken = "get this from the Nearby Now admin site";
public ActionResult NearbyNowReviews(String State, String City)
{
var agent = Request.UserAgent;
var wc = new WebClient();
ViewBag.NearbyNowContent = wc.DownloadString(String.Format(api,
HttpUtility.UrlEncode(StorefrontToken),
HttpUtility.UrlEncode(State),
HttpUtility.UrlEncode(City),
"", // zoomlevel
"", // radius
"", // showmap
"", // techemail
"", // mapscrollwheel
"", // fblike
"", // fbcomment
HttpUtility.UrlEncode(agent),
"")
); // count
return View();
}
}
public class ApiSampleController : Controller
{
private const string api =
"https://api.sidebox.com/plugin/nearbyserviceareareviewcombo?storefronttoken={0}&state={1}&city={2}&zoomlevel={3}&radius={4}&showmap={5}&techemail={6}&mapscrollwheel={7}&fblike={8}&fbcomment={9}&agent={10}";
private const string StorefrontToken = "get this from the Nearby Now admin site";
public ActionResult NearbyNowReviews(String State, String City)
{
var agent = Request.UserAgent;
var wc = new WebClient();
ViewBag.NearbyNowContent = wc.DownloadString(String.Format(api,
HttpUtility.UrlEncode(StorefrontToken),
HttpUtility.UrlEncode(State),
HttpUtility.UrlEncode(City),
"", // zoomlevel
"", // radius
"", // showmap
"", // techemail
"", // mapscrollwheel
"", // fblike
"", // fbcomment
HttpUtility.UrlEncode(agent))
); // count
return View();
}
}
public class ApiSampleController : Controller
{
private const string api =
"https://api.sidebox.com/plugin/nearbyservicearea?storefronttoken={0}&state={1}&city={2}&zoomlevel={3}&radius={4}&showmap={5}&techemail={6}&mapscrollwheel={7}&fblike={8}&fbcomment={9}&agent={10}&count={11}";
private const string StorefrontToken = "get this from the Nearby Now admin site";
public ActionResult NearbyNowReviews(String State, String City)
{
var agent = Request.UserAgent;
var wc = new WebClient();
ViewBag.NearbyNowContent = wc.DownloadString(String.Format(api,
HttpUtility.UrlEncode(StorefrontToken),
HttpUtility.UrlEncode(State),
HttpUtility.UrlEncode(City),
"", // zoomlevel
"", // radius
"", // showmap
"", // techemail
"", // mapscrollwheel
"", // fblike
"", // fbcomment
HttpUtility.UrlEncode(agent),
"")
); // count
return View();
}
}
<--Add the required css to your Head-->
<link href="https://d2gwjd5chbpgug.cloudfront.net/v4.2/css/nnplugin.min.css" rel="stylesheet" type="text/css" />
<--Somewhere in your page, ender the plugin content in your view using the following code:!-->
@Html.Raw(ViewBag.NearbyNowContent)
<--Make sure you include Query. Any flavor is fine-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<--Make sure you include the required Nearby Now Heatmap script-->
<script src="https://d2gwjd5chbpgug.cloudfront.net/v3/scripts/heatmap.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment