Skip to content

Instantly share code, notes, and snippets.

@adamdilek
Created December 29, 2011 22:34
Show Gist options
  • Select an option

  • Save adamdilek/1536500 to your computer and use it in GitHub Desktop.

Select an option

Save adamdilek/1536500 to your computer and use it in GitHub Desktop.
Example PHP Code for Location API
<?php header("content-type: text/html; charset=utf-8"); ?>
<?php
function get($request){
$session=curl_init($request);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response=curl_exec($session);
curl_close($session);
return json_decode($response);
}
$cities=get("http://pigon.ws/location/cities");
foreach($cities as $city) {
echo $city->id;
echo $city -> name;
echo "<br>";
$districts=get("http://pigon.ws/location/districts?city_id=".$city->id);
foreach($districts as $district) {
echo "-";
echo $district->id;
echo $district->name;
echo "<br>";
$regions=get("http://pigon.ws/location/regions?district_id=".$district->id);
foreach($regions as $region) {
echo "--";
echo $region->id;
echo $region->name;
echo "<br>";
$streets=get("http://pigon.ws/location/streets?region_id=".$region->id);
foreach($streets as $street) {
echo "---";
echo $street->name;
}
echo "<br>";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment