PHP Samples
1. HTTP RAW POST
PHP with CURL
// Define the proper Endpoint. Check the chapters on the endpoints to get the correct one for your usage
$endpoint = 'https://staging.hotel-spider.ch/ota/OTA_HotelAvailNotifRQ/2014A'
$Request = <<< XML
<?xml version="1.0" encoding="utf-8"?>
<OTA_HotelAvailNotifRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opentravel.org/OTA/2003/05" xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_HotelAvailNotifRQ.xsd" TimeStamp="2012-10-05T14:20:50" Target="Test" Version="1.005">
<POS>
<Source>
<RequestorID Type="5" ID="*************" MessagePassword="*************"></RequestorID>
</Source>
</POS>
<AvailStatusMessages>
<AvailStatusMessage BookingLimit="25" LocatorID="1">
<StatusApplicationControl Start="2015-09-24" End="2015-09-24" InvTypeCode="*************"/>
</AvailStatusMessage>
</AvailStatusMessages>
</OTA_HotelAvailNotifRQ>
XML;
//open connection and set endpoint
$ch = curl_init($endpoint);
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $Request);
//execute post
$Response= curl_exec($ch);
//close connection
curl_close($ch);PHP without CURL
// Define the proper Endpoint. Check the chapters on the endpoints to get the correct one for your usage
$endpoint = 'https://staging.hotel-spider.ch/ota/OTA_HotelAvailNotifRQ/2014A'
$Request = <<< XML
<?xml version="1.0" encoding="utf-8"?>
<OTA_HotelAvailNotifRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opentravel.org/OTA/2003/05" xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_HotelAvailNotifRQ.xsd" TimeStamp="2012-10-05T14:20:50" Target="Test" Version="1.005">
<POS>
<Source>
<RequestorID Type="5" ID="*************" MessagePassword="*************"></RequestorID>
</Source>
</POS>
<AvailStatusMessages>
<AvailStatusMessage BookingLimit="25" LocatorID="1">
<StatusApplicationControl Start="2015-09-24" End="2015-09-24" InvTypeCode="*************"/>
</AvailStatusMessage>
</AvailStatusMessages>
</OTA_HotelAvailNotifRQ>
XML;
$params = array('http' => array(
'method' => 'POST',
'content' => $Request
));
$ctx = stream_context_create($params);
$fp = @fopen($endpoint , 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $endpoint , $php_errormsg");
}
$Response = @stream_get_contents($fp);
if ($Response === false) {
throw new Exception("Problem reading data from $endpoint , $php_errormsg");
}
2. SOAP
To be extended
The below example needs to be completed.
PHP with SoapClient class
// Define the proper Endpoint. Check the chapters on the endpoints to get the correct one for your usage
$wsdl = 'https://staging.hotel-spider.ch/soap/OTA_HotelAvailNotifRQ/2014A'
$Request = <<< XML
<?xml version="1.0" encoding="utf-8"?>
<OTA_HotelAvailNotifRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opentravel.org/OTA/2003/05" xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_HotelAvailNotifRQ.xsd" TimeStamp="2012-10-05T14:20:50" Target="Test" Version="1.005">
<POS>
<Source>
<RequestorID Type="5" ID="*************" MessagePassword="*************"></RequestorID>
</Source>
</POS>
<AvailStatusMessages>
<AvailStatusMessage BookingLimit="25" LocatorID="1">
<StatusApplicationControl Start="2015-09-24" End="2015-09-24" InvTypeCode="*************"/>
</AvailStatusMessage>
</AvailStatusMessages>
</OTA_HotelAvailNotifRQ>
XML;
$client = new SoapClient($wsdl);
try {
return $client->__soapCall("OTA_HotelAvailNotif", array($subscribeRequest));
} catch (Exception $e) {
throw new Exception('ERROR in ' . __METHOD__, $e, $client->__getLastRequestHeaders(), $client->__getLastRequest(), $client->__getLastResponseHeaders(), $client->__getLastResponse());
}