home > support > API > Marketplace API > PHP Client Library

Fork me on GitHub

TourCMS API - PHP Client Library

Download PHP Client Library (v1.5)  Fork on GitHub

About the Library

The TourCMS API PHP Client Library class is intended to provide a simple wrapper for the TourCMS Marketplace API. It takes care of authentication and exposes wrapper functions for all methods currently available in the API.

Requires PHP 5 or above.


Getting started

Step 1: Make sure you have some products available

If you have a Supplier account please review the checklist at the top of the API information page.

If you have a Partner account you will need to connect to at least one Supplier who has products available. You can check by logging in to your Partner account and clicking "Search & Book". If you can see some products visible then you are good to go, if not you will need to connect to some additional Suppliers, or ask your existing connections to load some products.

Step 2: Include the wrapper library

// Include the TourCMS library
include 'tourcms.php';

Step 3: Create a new instance of the TourCMS class

Description

object TourCMS ( int $mp, string $k [, string $res = "raw" ])

Parameters

$mp Your Marketplace Partner ID. If you are a Supplier set this to 0, if you are a Partner then you can find your ID by logging in to TourCMS and checking the API settings page of your account.
$k Your API Private Key. This can be found/set in the API settings page in your account.
$res The result type you would like back. By default results will be returned as XML, specify "simplexml" if you would prefer to get a SimpleXML object back. The majority of examples on this site will use SimpleXML.

Example

// Create a new Instance of the TourCMS API class
$tourcms = new TourCMS(0, "YOUR_PASSWORD_HERE", "simplexml");

Step 4: Call the API methods you are interested in

The simplest call is one to get back information on your current API rate limit:

// Set the Channel ID
// For Suppliers this can be found in the API settings page
// For Partners this will be 0
$channel_id = 0;

// Query the TourCMS API
$result = $tourcms->api_rate_limit_status($channel_id);

// Print out the remaining hits
print  'Remaining hits: '.$result->remaining_hits;

Output:

Remaining hits: 500

Additional PHP examples are available on the individual pages linked from the method list.


Licensing

The library is provided under an MIT license which allows you absolute flexibility in re-use and distribution, you may use the library in your own closed source or open source applications. If you would prefer to receive the library under another license please contact us.


Version history

1.5
31 Oct 2011. Added wrappers for updating a Tour/Hotel
1.4
17 Oct 2011. Added wrappers for creating new bookings
1.3
10 Sept 2011. Made the generic request method public rather than protected
1.2
09 Sept 2011. Added wrappers for searching/viewing/updating bookings, customers and enquiries
1.1
Fixed regression on 'Fail Keynotfound' issue on api_rate_limit_status for supplier accounts
1.0
Added new Hotel Search APIs
No known issues so jumping to Version 1.0
0.5
Fix for 'Fail Keynotfound' issue on api_rate_limit_status for supplier accounts
0.3
Fix for 'missing parameter' issue on show_tour_departures and show_tour_freesale
Updated to use RFC 2616 compatible format for Date header
0.2
Initial public release

More information

© 2003-2012 Travel UCD Limited. All rights reserved. TourCMS® is a registered trademark of Travel UCD Limited, United Kingdom. View Privacy policy.