PHP Store Locator Software Sample Code

Using the Bullseye API, you can easily build a custom store locator software solution that can be integrated seamlessly with your website or mobile app.  

The following sample code shows how to access one of our REST services via PHP, using CURL.

It simply calls the GetCatSum service, then decodes the response from JSON into an associative array.

Example: 
<?php
 
$myUrl = 
"http://ws.bullseyelocations.com/RestSearch.svc/GetCatSum" .
"?ClientId=999&ApiKey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" .
"&Latitude=40.665505&Longitude=-74.267242&Radius=25";
print "$myUrl <br/>"; 
 
$myHeaders = array(
'Accept: application/json',
'Content-type: application/json'
);
 
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $myUrl);
curl_setopt($handle, CURLOPT_HTTPHEADER, $myHeaders);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
 
$response = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
 
print "return code = $code <br/>";
print "response = <br/> $response <br/><br/>";
 
$myRespArr = json_decode($response, true);
var_dump($myRespArr);
 
?>
<?php
/* This next sample shows how to call the DoSearch2 method. */
 
$myUrl = "http://ws.bullseyelocations.com/RestSearch.svc/DoSearch2" .
"?ClientId=999&ApiKey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx " .
"&Latitude=40.665505&Longitude=-74.267242&Radius=25" .
"&UserIPAddress=1.2.3.4" .
"&StartIndex=0&PageSize=25";
 
print "$myUrl <br/>"; 
$method = "GET";
 
$myHeaders = array(
	'Accept: application/json',
	'Content-type: application/json'
	);
 
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $myUrl);
 
curl_setopt($handle, CURLOPT_HTTPHEADER, $myHeaders);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
 
$response = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
 
print "return code = $code <br/>";
 
$myRespArr = json_decode($response, true);
print $myRespArr["TotalResults"] . " total results.<br/>\n";
print "<pre>";
var_dump($myRespArr);
print "</pre>";
?>