1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <?php
$requesturl = 'http://wxs.ign.fr/MYKEY/geoportail/ols?';
$requestxml = '<?xml version="1.0" encoding="UTF-8"?><XLS xmlns:xls="http://www.opengis.net/xls" xmlns:gml="http://www.opengis.net/gml" xmlns="http://www.opengis.net/xls" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="http://www.opengis.net/xls http://schemas.opengis.net/ols/1.2/olsAll.xsd"><RequestHeader/><Request requestID="1" version="1.2" methodName="LocationUtilityService"><GeocodeRequest returnFreeForm="false"><Address countryCode="StreetAddress"><StreetAddress><Street>1 rue Marconi</Street></StreetAddress><Place type="Municipality">Metz</Place><PostalCode>57000</PostalCode></Address></GeocodeRequest></Request></XLS>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $requesturl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', 'Content-length:'.strlen($requestxml)));
curl_setopt($ch, CURLOPT_REFERER, 'http://localhost');
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestxml);
$reponse = curl_exec($ch);
echo $reponse;
$xmlr = new SimpleXMLElement($reponse);
foreach($xmlr->entry as $coord){
echo $coord->title . "\n";
}
?> |
Partager