toBook.com - XML interface
This is the documentation of the XML interface 1.0 of toBook.com and a guide how an extranet can develop its services to connect and retrieve list of roomtypes, or update rates, availability, along with other functions like booking confirmation. This direct integration would facilitate the hotels to manage their online distribution with more efficiency and ease.
List of functions:
- Retrieve list of hotels belonging to a hotelchain
- Retrieve list of roomtypes belonging to a hotel
- Retrieve availability information (number of rooms available, rates and minimum length of stay)
- Retrieve reservations and cancellations (updated: December 4, 2009)
- Update availability information
- Confirm reservations and cancellations
Additional information
To use the service, you must generate a POST request with text/xml as content type.
Request in Perl
use LWP::UserAgent;
use HTTP::Request::Common;
# set up request parameters
my $url = "target URL";
my $content = "XML content to be submitted";
# generate the request
my $userAgent = LWP::UserAgent->new(agent => "perl post");
my $response = $userAgent->request(POST $url, Content_Type => "text/xml", Content => $content);
# print out the response
print $response->content;
Request in C# .NET
using System;
using System.IO;
using System.Net;
using System.Text;
public void GenerateRequest()
{
// set up request parameters
String url = "target URL";
String xmlContent = "XML content to be submitted";
// xmlResponse contains the response XML as string
String xmlResponse = PostRequest(url, xmlContent);
}
public string PostRequest(string URL, string xmlContent){
String Response = null;
Byte[] buffer = Encoding.UTF8.GetBytes(xmlContent);
// in case of ASCII encoding
// Byte[] buffer = Encoding.ASCII.GetBytes(xmlContent);
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(URL);
WebReq.Method = "POST";
WebReq.ContentType = "text/xml";
WebReq.ContentLength = buffer.Length;
Stream PostData = WebReq.GetRequestStream();
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
Response = _Answer.ReadToEnd();
return Response.Trim();
}
While developing, you can use http://xml.tobook.com/poster.asp to submit requests.Please note, that the URL field must contain the http:// prefix, and the XML must not have any whitespace in front of the first node.
When testing function #3 and #5 (retrieve and update availability information), you can use http://xml.tobook.com/testHotelInfo.asp to have a visual view of the currently stored availability data.
There are four reservations uploaded in the system for testing, one is to be confirmed, while the others are to be cancelled.
When testing #6 (confirm reservations / cancellations), you can use
http://xml.tobook.com/resetTestReservations.asp
to reset their settings back to default after having them confirmed or cancelled.