I am working on a simple PHP code which is supposed to extract specific data from a txt-file. The txt-file comes from a GTFS-RT API. I would like to keep it as simple as possible, and thereby not use the protocol-buffer file.
I am having trouble extracting the data.
I have tried treating the file as JSON, however, the result is empty. I have tried both Json_encode and Json_decode. I have tried print_r, var_dump and echo to see how the data is built, but I am stuck.
The data is built as follows:
https://i.stack.imgur.com/chl8S.png
<?php
$data=file_get_contents("https://gtfsr-pp.samtrafiken.se/otraf/TripUpdates.pb?key={API-key}");
echo $data->entity[0]->id;
?>
This code comes back empty.
And yes, I have the correct API-key, I just hide the key here.