PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Dave Smith   PHP Flight Schedules   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: PHP Flight Schedules
Get real time flight schedules using aviationStack
Author: By
Last change:
Date: 4 years ago
Size: 1,137 bytes
 

Contents

Class file image Download
<?php
/*
example usage
aviationStack ver 1.0

You must get an API key from https://aviationstack.com/product
and enter it in the aviationstack.class.php file

For complete documentation on each endpoint and available paramaters
see https://aviationstack.com/documentation
*/

//turning off low level notices
error_reporting(E_ALL ^ E_NOTICE);

//instantiate the class
include('aviationstack.class.php');
$aviation = new aviationStack();

//set the end point to use
$aviation->setEndPoint('flights');

//set the parameters
//in this example, we are getting all flights departing from San Francisco
//and arriving in Dallas/Fort Worth
$aviation->setParam('flight_date','2019-12-30');
$aviation->setParam('dep_iata','SFO');
$aviation->setParam('arr_iata','DFW');

//show request
echo $aviation->buildRequest().'<br>';

//get the response
$aviation->getResponse();

//check for errors
if( !empty($aviation->errorCode) ){
   
//error returned
   
echo $aviation->errorCode.': '.$aviation->errorText;
}

//displaying the full response
echo '<pre>';
var_dump($aviation->response);
echo
'<pre>';
?>