Code samples

Here are some code examples on how to send and receive data from our API endpoint.

<?php
//Building the XML:
$xml = new SimpleXMLElement('<aerocrs/>');
$params = $xml->addChild('parms');
$params->addChild('codeformat', 'IATA');

//Preparing the POST using cURL
$postString=($xml->asXML());
//Base url '/' method name, case sensitive
$url = 'https://api.aerocrs.com/v5/getSchedule';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSLVERSION,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
               'Content-type: application/xml',
               'Content-length: ' . strlen($postString),
  		'auth_id: 17C3333D-6358-420C-A322-C71EA9592651',
  		'auth_password: test'
             ));
$response = curl_exec($ch);
curl_close($ch);
 
//Taking the XML to array
$responsefromaerocrs = (array)simplexml_load_string($response);
 
//Now you have an array you can work with and parse it correctly to your application.
 
?>