I need to retrieve data from the following URL:
http://lt.ff.ryanair-bilietai.lt.eturas.lt/flights/webservices/lowest/?limit=50&print=0&way_type=one_way
I need to show all departures cities, name with price, from "departureCity":"Kaunas" and format that data as a list,
The list would look something like this:
<ul>
<li>City Price</li>
<li>Vilnius 59 Lt</li>
</ul>
What is needed to actually pull the JSON data from the external URL? Once pulled how do I manipulate that data so a list can be generated?
You can get the data from url like this:
$limit = $_GET["limit"];
$print = $_GET["print"];
$way_type = $_GET["way_type"];
These are the values from the url string, you can use them to search from the database or any data source you want.
Here is an example of how you can get the data from the json source:
$jsonData = json_decode(file_get_contents("http://lt.ff.ryanair-bilietai.lt.eturas.lt/flights/webservices/lowest/?limit=50&print=0&way_type=one_way"));
echo "<ul>";
foreach($jsonData as $key=>$value){
if($value->departureCity == "Kaunas"){
echo "<li>" . $value->priceAdult . "</li>";
}
}
echo "</ul>";
This will print all the city prices originating from Kaunas. For more info, use this after line 1:
print_r($jsonData);
try
<?php
$data = file_get_contents("http://lt.ff.ryanair-bilietai.lt.eturas.lt/flights/webservices/lowest/?limit=50&print=0&way_type=one_way");
$jsondata = json_decode($data);
// this will print array you can play with it now
print_r($jsondata);
?>