0
People like I get the data in php of latitude and longitude of this url below
https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/0ozWRQqxiMnv5bqJzSUIMyUIIbMGrP5qu/message.json
0
People like I get the data in php of latitude and longitude of this url below
https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/0ozWRQqxiMnv5bqJzSUIMyUIIbMGrP5qu/message.json
0
You can use the function file_get_contents()
. It would look something like:
$conteudo = file_get_contents('https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/0ozWRQqxiMnv5bqJzSUIMyUIIbMGrP5qu/message.json');
echo $conteudo;
Since it is a JSON, we can transform it into an object using the function json_decode($conteudo)
. If you want to see the exact JSON format you can use the following code
echo '<pre>';
print_r($conteudo);
echo '</pre>';
Now that you already have the content in an object, we can make a foreach
to scroll through all JSON content
foreach ($conteudo->response->feedMessageResponse->messages->message as $key) {
print_r('Latitude: '.$key->latitude);
echo ' - ';
print_r('longitude: '.$key->longitude);
echo '<br>';
}
The whole code went like this then:
$conteudo = json_decode(file_get_contents('https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/0ozWRQqxiMnv5bqJzSUIMyUIIbMGrP5qu/message.json'));
foreach ($conteudo->response->feedMessageResponse->messages->message as $key) {
print_r('Latitude: '.$key->latitude);
echo ' - ';
print_r('longitude: '.$key->longitude);
echo '<br>';
}
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Phelipe and that’s right I just don’t know now and catch latitude and longitude rsrs
– Hemerson Prestes
I complemented my answer. Now it takes the values you wanted. Just understand the structure of JSON and go through it.
– Phelipe
Perfect friend of mine
– Hemerson Prestes
can take me only one more doubt as I would to catch only the last latitude and longitude ?
– Hemerson Prestes
can take me only one more doubt as I would to catch only the last latitude and longitude ?
– Hemerson Prestes