home > support > API > Marketplace API > booking creation > get booking key
Note this step is only required for Tour Operators (not Marketplace Agents).
The process is:
The key is valid for 24 hours for that customer and there is no requirement to keep requesting the key from TourCMS within that 24 hour period. Each new customer however will require their own key. So for example you may want to request a booking key once when a customer first enters a booking process and then store it in their session.
This process will ensure that TourCMS picks up any Marketplace affiliate/PPC tracking information previously stored in the users browser by retrieving a cookie and recording the details alongside the newly created booking key.
Get a URL for use in retrieving a new booking key, ensures marketplace data (clicks, referrer) is maintained on the final booking / customer record.
Only for use by Tour Operators (mandatory step), not required when the API is being used by Marketplace Agents.
Endpoint | /c/booking/new/get_redirect_url |
Formats | XML |
Example | /c/booking/new/get_redirect_url.xml POST data:
|
Verb | POST |
PHP examples use the PHP Client Library with SimpleXML
object get_booking_redirect_url ( SimpleXmlElement $url_data, int $channel )
This is a two step example, the first step calls the API and then redirects the customer to TourCMS, the second step will then accept the customer back once TourCMS has finished and process the querystring parameters it has added.
Step 1: Call the API then redirect the customer to TourCMS
// Create a new SimpleXMLElement to hold the url
$url_data = new SimpleXMLElement('<url />');
// Response URL is the page we use to receive the customer back
$url_data->addChild('response_url', 'https://example.com/step2.php');
// Call TourCMS API
$result = $tourcms->get_booking_redirect_url($url_data, $channel);
// Process the redirect URL
$redirect_url = $result->url->redirect_url;
// Redirect the customer to TourCMS
header("Location: " . $redirect_url);
Step 2: TourCMS has redirected the customer back, we retrieve our key
// Retrieve the new booking Key TourCMS has generated
print "The booking key is: " . $_GET['booking_key'];
The booking key is: 0_0_12345678_1234_123abcd456fgh789123
This booking key will of course not be displayed to the customer, it is just required for Tour Operator API use when subsequently calling the Start New Booking API method.
C# examples use the .Net Client Library
XmlDocument GetBookingRedirectUrl (XmlDocument urlData, int channelId)
VB examples use the .Net Client Library
XmlDocument GetBookingRedirectUrl (XmlDocument urlData, Integer channelId)
NodeJS examples use the NodeJS Wrapper
TourCMS.getBookingRedirectUrl({
channelId: 3930,
responseUrl: "http://www.example.com",
callback: function(response) {
console.log(response.url.redirect_url);
}
});
https://live.tourcms.com/..........
Looking for sample code in a different language? TourCMS and community provided API libraries
Enter your TourCMS API credentials below to call the Get Booking Redirect Url endpoint.
There are no querystring parameters.
XML Node | Notes | ||||
---|---|---|---|---|---|
url |
The root XML element, must contain:
|
XML Node | Notes | ||||
---|---|---|---|---|---|
request | Confirmation of the request that you sent | ||||
error | Any error message returned, if there is no error this will just contain the text OK. | ||||
url |
|