protected static function build_request($xml_args, $opts) { self::$xml = new SimpleXMLElement("<Easytobook />"); $request = self::$xml->addChild('Request'); $request->addAttribute('target', parent::$env); $authentication = $request->addChild('Authentication'); $authentication->addAttribute('username', parent::$username); $authentication->addAttribute('password', parent::$password); foreach ($xml_args as $key => $value) { if ($key == 'campaignid') { $authentication->addAttribute($key, parent::$campaignid); continue; } if ($key == 'Function') { $authentication->addChild($key, $value); continue; } self::iterate_values($request, $key, $value); } if (isset($opts['plain_xml']) && $opts['plain_xml'] === true) { return self::build_xml_document(self::$xml); } else { return self::$xml; } }
/** * Makes reservations at a given hotel, for given room types, number of persons, arrival and departure dates at a specified rate. * Returns details for all bookings successfully made or failed. * * Important! In order to finish booking, you shoud provide the TotalChargeable price to this function. * Please use the TotalChargeable that you get from GetHotelAvailability function. We advise always to perform GetAvailability * call right before CreateBooking. With regards to SearchCityAvailability, information given on this call may be cached and thus * outdated. You have significantly more chance to be refused with booking if you rely on data received from SearchCityAvailability. * * Please note that this function is HTTPS (SSL) only. You will be able to use it over HTTP only on the test environment * Please note that on live enviroment, IP address of the requestor should be in our white list. You will need to provide us * all possible IP addresses / netmasks that are going to be used for live reservations before going live. We work on white lists * approach and will reject all reservations that come from outside our IP white lists. * * @param */ function CreateBooking($xml_args) { $xml_args = array_merge(array('Function' => 'CreateBooking', 'campaignid' => 1, 'Currency' => 'EUR', 'Language' => 'en'), $xml_args); $xml = EasytobookXML::build_request($xml_args, array('plain_xml' => true)); $response = EasytobookHTTP::post($xml); $xml_obj = simplexml_load_string($response); return $xml_obj->xpath('/soap:Envelope/soap:Body/EasytobookResponse/Response'); }