Upload files to "/"
This commit is contained in:
58
getLocation.php
Normal file
58
getLocation.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(-1);
|
||||
//$location = $_POST['latitude'];
|
||||
//echo $location;
|
||||
|
||||
$lat = $_POST['latitude'];
|
||||
$lon = $_POST['longitude'];
|
||||
|
||||
$latlon = "lat={$lat}&lon={$lon}";
|
||||
|
||||
//echo "url?";
|
||||
//echo "posisjon?{$latlon}&maks_avstand=20&maks_antall=1&konnekteringslenker=true&detaljerte_lenker=true&srid=WGS84&trafikantgruppe=K";
|
||||
|
||||
// create a new cURL resource
|
||||
$ch = curl_init();
|
||||
$url = "https://nvdbapiles.atlas.vegvesen.no/vegnett/api/v4/";
|
||||
$querystr = "posisjon?{$latlon}&maks_avstand=20&maks_antall=1&konnekteringslenker=true&detaljerte_lenker=true&srid=WGS84&trafikantgruppe=K";
|
||||
|
||||
// set URL and other appropriate options
|
||||
curl_setopt($ch, CURLOPT_URL, $url . $querystr);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
|
||||
// grab URL and pass it to the browser
|
||||
curl_exec($ch);
|
||||
if(curl_exec($ch) === false)
|
||||
{
|
||||
echo 'Curl error: ' . curl_error($ch);
|
||||
}
|
||||
else
|
||||
{
|
||||
// echo 'Operation completed without any errors';
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Decoding JSON data
|
||||
$decodedData = json_decode($response, true);
|
||||
|
||||
// Outputting JSON data in
|
||||
// Decoded form
|
||||
//echo $ch;
|
||||
//echo $response;
|
||||
|
||||
echo "$lat, $lon";
|
||||
|
||||
echo "<br><br>Kortform:";
|
||||
echo $decodedData[0]['vegsystemreferanse']['kortform'];
|
||||
|
||||
echo "<br><br>Raw data";
|
||||
echo '<pre>';
|
||||
print_r($decodedData);
|
||||
echo '<br><br>';
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user