Created
December 29, 2011 22:34
-
-
Save adamdilek/1536500 to your computer and use it in GitHub Desktop.
Example PHP Code for Location API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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