PHP code example of tourcms / tourcms-php

1. Go to this page and download the library: Download tourcms/tourcms-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tourcms / tourcms-php example snippets


use TourCMS\Utils\TourCMS as TourCMS;

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

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

// 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
 
// Set a User-Agent
  $tourcms->set_user_agent('Example Tours Website');

// 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);

// 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);

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

$tourcms->set_user_agent("Example Tours Website");

$tourcms->set_request_identifier("98b41172-4db9-464e-9db8-f31ae92ffbab");

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