44 lines
1.1 KiB
Markdown
44 lines
1.1 KiB
Markdown
```php
|
|
<!-- test1.php -->
|
|
|
|
<?php
|
|
|
|
//The URL with parameters / query string.
|
|
// Escape: $str = preg_replace('/[^a-z\d ]/i', '', $str);
|
|
|
|
$url='https://api.tomtom.com/search/2/search/Am%20Kapellchen%2021%2C%2041470%20Neuss.json?lat=37.337&lon=-121.89&minFuzzyLevel=1&maxFuzzyLevel=2&view=Unified&relatedPois=off&key=xcA6NjLwDPmayP6y56AoVoloz1iohbUV';
|
|
|
|
//we use file_get_contents to GET the URL in question.
|
|
$contents = file_get_contents($url);
|
|
|
|
$result = json_decode($contents);
|
|
$lat = $result->results[0]->position->lat;
|
|
$lon = $result->results[0]->position->lon;
|
|
|
|
echo "Lat=" . $lat . ", Lon=" . $lon;
|
|
|
|
```
|
|
|
|
````php
|
|
<?php
|
|
|
|
//The URL with parameters / query string.
|
|
|
|
$url='https://api.tomtom.com/search/2/search/Am%20Kapellchen%2021%2C%2041470%20Neuss.json?lat=37.337&lon=-121.89&minFuzzyLevel=1&maxFuzzyLevel=2&view=Unified&relatedPois=off&key=xcA6NjLwDPmayP6y56AoVoloz1iohbUV';
|
|
|
|
//we use file_get_contents to GET the URL in question.
|
|
$contents = file_get_contents($url);
|
|
|
|
//If $contents is not a boolean FALSE value.
|
|
if($contents !== false){
|
|
//Print out the contents.
|
|
echo $contents;
|
|
}
|
|
```
|
|
|
|
````
|
|
|
|
|
|
|
|
|
|
|