Login | Register

The XML Footer

At the end of each request, you must provide a footer specifying the URL, the request type as well as some additional options. The example below is based on using PHP;

//Initialize handle and set options (required)http://api.coachhire.com/lib/api/?send=xml');  
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($ch, CURLOPT_TIMEOUT, 4);  
curl_setopt($ch, CURLOPT_POSTFIELDS, $request_xml); 
curl_setopt($ch, CURLOPT_REFERER, $_SERVER['HTTP_HOST']); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-type: application/atom+xml" )); 

//Execute the request and also time the transaction ( optional )
$start = array_sum(explode(' ', microtime()));
$result = curl_exec($ch); 
$stop = array_sum(explode(' ', microtime()));
$totalTime = $stop - $start;
 
//Check for errors ( again optional )
if ( curl_errno($ch) ) {
    $result = 'ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch);
} else {
    $returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
    switch($returnCode){
        case 200:
            break;
        default:
            $result = 'HTTP ERROR -> ' . $returnCode;
            break;
    }
}
 
curl_close($ch);

echo $result; 

Now we will look at the specific API calls. To assist in readability, the API footer information is not repeated for each example. However, the required component of the footer is needed for each API call being made.