2017 © Pedro Peláez
 

library tourcms-php

TourCMS API wrapper for PHP

image

tourcms/tourcms-php

TourCMS API wrapper for PHP

  • Wednesday, March 28, 2018
  • by paulslugocki
  • Repository
  • 15 Watchers
  • 6 Stars
  • 3,700 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 3 Open issues
  • 26 Versions
  • 41 % Grown

The README.md

PHP Wrapper for the TourCMS API

Installation

  1. Install Composer, add "tourcms/tourcms-php": "3.9.*", to the requires section of your composer.json:
  2. Ensure you are including composer's autoload.php, alternatively include TourCMS.php directly.

Installing Manually

  1. Download the source zip, extract to your web server
  2. Include TourCMS.php in your source

Upgrading from version 1.x

If you are upgrading from version 1.x of the library the latest TourCMS.php should be more or less a straight swap. The major change being that to adhere to PHP PSR-4 standards, the class is now namespaced. Broadly speaking there are two different ways to update existing code to account for this:, (*1)

Aliasing the namespace

If you already have a global include file that includes TourCMS.php you could add the following line immediately after TourCMS.php is included:, (*2)

use TourCMS\Utils\TourCMS as TourCMS;

Your existing code should then work as-is, for example when you create a new instance of the TourCMS class you would have:, (*3)

$tourcms = new TourCMS(0, 'YOUR_PASSWORD', 'simplexml');

Using the fully qualified name

Alternatively use the fully qualified name when you create a new instance of the class:, (*4)

$tourcms = new TourCMS\Utils\TourCMS(0, 'YOUR_PASSWORD', 'simplexml');

Usage

// Common configuration parameters

  // Marketplace ID will be 0 for Tour Operators, non-zero for Marketplace Agents
  // Agents can find their Marketplace ID in the API page in TourCMS settings
    $marketplace_id = 0;

  // API key will be a string, find it in the API page in TourCMS settings
    $api_key = "YOUR_KEY_HERE";

  // Timeout will set the maximum execution time, in seconds. If set to zero, no time limit is imposed.
    $timeout = 0;

  // Channel ID represents the Tour Operator channel to call the API against
  // Tour Operators may have multiple channels, so enter the correct one here
  // Agents can make some calls (e.g. tour_search()) across multiple channels
  // by entering a Channel ID of 0 or omitting it, or they can restrict to a
  // specific channel by providing the Channel ID
    $channel_id = 0;


// Create a new TourCMS instance
  // Optionally alias the namespace
  use TourCMS\Utils\TourCMS as TourCMS;
  $tourcms = new TourCMS($marketplace_id, $api_key, 'simplexml', $timeout);
  // 'simplexml' returns as a SimpleXMLObject
  // 'raw' returns the XML as as String

// Call the API
  // Here as a quick example we search for some tours
  $result = $tourcms->search_tours('', $channel_id);

// Display the output
  print_r($result);

Further Examples

API documentation on tourcms.com

Each API method in the TourCMS API documentation includes full PHP sample code., (*5)

Examples in this repository

Additionally there are some examples included in this repository, to run them:, (*6)

  1. Copy the src/examples directory to your web root
  2. Rename examples/config-example.php to examples/config.php
  3. Load your API credentials in the config file and ensure the path to TourCMS.php is correct
  4. Point your web browser at the examples folder

Environment test

The library can attempt to check your local environment and API credentials, useful if you are having trouble connecting. First off make sure you are including TourCMS.php, either via autoload or explicitly., (*7)

// Common configuration parameters

  // Marketplace ID will be 0 for Tour Operators, non-zero for Marketplace Agents
  // Agents can find their Marketplace ID in the API page in TourCMS settings
    $marketplace_id = 0;

  // API key will be a string, find it in the API page in TourCMS settings
    $api_key = "YOUR_KEY_HERE";

  // Channel ID represents the Tour Operator channel to call the API against
  // Tour Operators may have multiple channels, so enter the correct one here
  // Agents can leave this as 0 for the test
    $channel_id = 0;

// Create a new TourCMS instance
  // Optionally alias the namespace
  use TourCMS\Utils\TourCMS as TourCMS;
  $tourcms = new TourCMS($marketplace_id, $api_key, "simplexml");

// Call the environment test, the results will be displayed on the screen
$tourcms->test_environment($channel_id);

Response headers

TourCMS responds with some useful information in the response headers. There is a method to retrieve the last set of response headers via the PHP wrapper., (*8)

$headers = $tourcms->get_last_response_headers();
$remaining_limit = $headers["x-ratelimit-remaining"];

Override base URL

By default the base URL will point to TourCMS main production environment. There is a method to override this to point at another base URL, intended for testing purposes., (*9)

$tourcms->set_base_url("https://api.example.com");

The Versions

28/03 2018

dev-feature/TOURCMS-761_US_add-documentation

dev-feature/TOURCMS-761_US_add-documentation https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

28/03 2018

dev-feature/TOURCMS-851_US_add_documentation

dev-feature/TOURCMS-851_US_add_documentation https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

03/10 2017

dev-feature/TOURCMS-678_payworks_create_payment_endpoint

dev-feature/TOURCMS-678_payworks_create_payment_endpoint https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

16/06 2017

dev-master

9999999-dev https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

16/06 2017

3.1.0

3.1.0.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

16/06 2017

v3.1.0.x-dev

3.1.0.9999999-dev https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

16/06 2017

dev-release/3.1.0

dev-release/3.1.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

24/04 2017

dev-feature/TOURCMS-473-Add_start_new_agent_login

dev-feature/TOURCMS-473-Add_start_new_agent_login https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

03/11 2016

v3.0.7

3.0.7.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

12/10 2016

v3.0.6

3.0.6.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

28/07 2016

v3.0.5

3.0.5.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

17/03 2016

v3.0.4

3.0.4.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

17/03 2016

v3.0.3

3.0.3.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

17/03 2016

v3.0.2

3.0.2.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

17/03 2016

v3.0.1

3.0.1.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

17/03 2016

v3.0.0

3.0.0.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

15/03 2016

v2.0.4

2.0.4.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

23/02 2016

v2.0.3

2.0.3.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

23/02 2016

v2.0.2

2.0.2.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

04/02 2016

v2.0.1

2.0.1.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

15/12 2015

v2.0.0

2.0.0.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api tourcms

15/12 2015

1.x-dev

1.9999999.9999999.9999999-dev https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.2

 

api tourcms

21/11 2014

v1.8.3

1.8.3.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.2

 

api tourcms

06/08 2014

v1.8.2

1.8.2.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.2

 

api tourcms

06/08 2014

v1.8.1

1.8.1.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.2

 

api tourcms

05/08 2014

v1.8

1.8.0.0 https://github.com/TourCMS/tourcms-php

TourCMS API wrapper for PHP

  Sources   Download

MIT

The Requires

  • php >=5.2

 

api tourcms