|
|
@@ -0,0 +1,63 @@
|
|
|
+<?php
|
|
|
+ ini_set('display_errors', 1);
|
|
|
+ ini_set('display_startup_errors', 1);
|
|
|
+ error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
|
|
|
+
|
|
|
+ if(isset($_GET['text'])) {
|
|
|
+
|
|
|
+ $url = 'http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest';
|
|
|
+ $data = array('f' => 'pjson',
|
|
|
+ 'searchExtent' => '{"xmin":-0.5,"ymin":49.732307856286,"xmax":-1.97117692088061,"ymax":48.4,"spatialReference":{"wkid":84}}',
|
|
|
+ 'text' => $_GET['text']
|
|
|
+ );
|
|
|
+
|
|
|
+ //url-ify the data for the POST
|
|
|
+ $url_data = http_build_query($data);
|
|
|
+
|
|
|
+ $ch = curl_init();
|
|
|
+ //set the url, number of POST vars, POST data
|
|
|
+ curl_setopt($ch,CURLOPT_URL, $url);
|
|
|
+ curl_setopt($ch,CURLOPT_POST, true);
|
|
|
+ curl_setopt($ch,CURLOPT_POSTFIELDS, $url_data);
|
|
|
+
|
|
|
+ //So that curl_exec returns the contents of the cURL; rather than echoing it
|
|
|
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
|
|
|
+
|
|
|
+ //execute post
|
|
|
+ $result = curl_exec($ch);
|
|
|
+
|
|
|
+ echo $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($_GET['address'])|isset($_GET['magicKey'])) {
|
|
|
+
|
|
|
+ $url = 'http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find';
|
|
|
+
|
|
|
+ $data = array('f' => 'pjson',
|
|
|
+ 'searchExtent' => '{"xmin":-0.5,"ymin":49.732307856286,"xmax":-1.97117692088061,"ymax":48.4,"spatialReference":{"wkid":84}}',
|
|
|
+ 'magicKey' => $_GET['magicKey'],
|
|
|
+ 'text' => $_GET['address']
|
|
|
+ );
|
|
|
+
|
|
|
+ //url-ify the data for the POST
|
|
|
+ $url_data = http_build_query($data);
|
|
|
+
|
|
|
+// var_dump($url_data);
|
|
|
+
|
|
|
+ $ch = curl_init();
|
|
|
+ //set the url, number of POST vars, POST data
|
|
|
+ curl_setopt($ch,CURLOPT_URL, $url);
|
|
|
+ curl_setopt($ch,CURLOPT_POST, true);
|
|
|
+ curl_setopt($ch,CURLOPT_POSTFIELDS, $url_data);
|
|
|
+
|
|
|
+ //So that curl_exec returns the contents of the cURL; rather than echoing it
|
|
|
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
|
|
|
+
|
|
|
+ //execute post
|
|
|
+ $result = curl_exec($ch);
|
|
|
+
|
|
|
+ echo $result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+?>
|