file_get_contents - failed to open stream: HTTP request failed
The problem is that your url is read literally due to '
.
If you use "
then the variables in the string will be used as variables but now your string is '...apikey=$api'
instead of '...apikey=sdflsdksdksdsdskd'
So change the line
$json_url = file_get_contents('https://api.sandbox.amadeus.com/v1.2/flights/low-fare-search?origin=$origin&destination=$destination&departure_date=$departure_date&return_date=$return_date&number_of_results=$number_of_results&apikey=$apikey');
To
$json_url = file_get_contents("https://api.sandbox.amadeus.com/v1.2/flights/low-fare-search?origin=$origin&destination=$destination&departure_date=$departure_date&return_date=$return_date&number_of_results=$number_of_results&apikey=$apikey");
file_get_contents failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in
file_get_contents (read the tip on blue rectangle) can be easily blocked on server side through php.ini avoid using it. When you want to get data from an other site use curl instead. http://php.net/manual/en/book.curl.php, there are plenty of options that you can use with curl, by playing a bit the following code can work with your url.
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_URL,"https://cgi.ebay.com/ws/eBayISAPI.dll?ViewItemRevisionDetails&item=272908801183");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13");
$data = curl_exec($ch);
curl_close($ch);
and by echoing the $data varible you can see the whole page.
echo $data;
you can try parsing the data from the page by utilizing php DOM Methods and convert them to the data type you want (object class, array etc).
Related Topics
PHP Hierarchical Array - Parents and Childs
Remove All the Line Breaks from the HTML Source
PHP Foreach Loop Through Multidimensional Array
How to Count Days Between Two Dates in PHP
Create a Dynamic MySQL Query Using PHP Variables
Understanding PHP & (Ampersand, Bitwise And) Operator
When to Pass-By-Reference in PHP
Executing a Shell Script from a PHP Script
Post and Get at the Same Time in PHP
Retrieve All Hashtags from a Tweet in a PHP Function
Get Week Number in Month from Date in PHP
Upload Multiple Files in Codeigniter
Resize Images in PHP Without Using Third-Party Libraries
How to Read Png Metadata from PHP