PHP code example of tourboks / apiclient

1. Go to this page and download the library: Download tourboks/apiclient 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/ */

    

tourboks / apiclient example snippets






te: Before go live change environment to LIVE
$config = new Tourboks\TourboksConfig([
    'member_username' => 'test',
    'member_password' => 'test',
    'environment' => 'STAGING',
]);

$requestParameters = [
    'product_id' => 23,
    'locale_id' => 1,
    'currency' => 'EUR',
];
$request = new Tourboks\Request\ProductDetails($requestParameters);
$request->setConfig($config);
try {
    $response = $request->perform();
    $data = $response->getData();
} catch (\Tourboks\Exceptions\TourboksResponseException $e) {
    $message = $e->getMessage();
}


$body = [
    'localeId' => '',
    'format' => '',
    'pageNumber' => 1,
    'keyword' => '',
    'category' => '',
    'sportTeam' => '',
    'dateFrom' => '',
    'dateTo' => '',
    'language' => '',
    'priceFrom' => '',
    'priceTo' => '',
    'durationFrom' => '',
    'durationTo' => '',
    'isBestSeller' => '',
    'meetTheLocals' => '',
    'distanceFrom' => '',
    'hasConfirmation' => '',
    'showTestProducts' => '',
];
$request = new Tourboks\Request\ProductSearch([], $body);
$request->setConfig($config);
try {
    $response = $request->perform();
    $data = $response->getData();
} catch (\Tourboks\Exceptions\TourboksResponseException $e) {
    $message = $e->getMessage();
}


$body = [
    'productId' => '23',
    'dateFrom' => '2018-08-12',
    'dateTo' => '2018-10-30'
];
$request = new Tourboks\Request\ProductAvailableDates([], $body);
$request->setConfig($config);
try {
    $response = $request->perform();
    $data = $response->getData();
} catch (\Tourboks\Exceptions\TourboksResponseException $e) {
    $message = $e->getMessage();
}

$body = [
    "productId" => "23",
    "date" => "2018-08-13",
    "currency" => "EUR",
    "persons" => [
        "personType" => "0",
        "numItems" => "2"
    ]
];
$request = new Tourboks\Request\ProductAvailability([], $body);
$request->setConfig($config);
try {
    $response = $request->perform();
    $data = $response->getData();
} catch (\Tourboks\Exceptions\TourboksResponseException $e) {
    $message = $e->getMessage();
}


$body = [
    "isInvoice" => 0,
    "addressAdditional" => "",
    "zip" => "10077",
    "title" => 0,
    "mytbIds" => "",
    "country" => 199,
    "currency" => "EUR",
    "city" => "Taipei ",
    "vat" => "",
    "activity" => "",
    "products" => [[
        "variantId" => "0",
        "extras" => [],
        "componentKey" => "",
        "id" => 23,
        "timeslots" => 14449,
        "personType" => [[
            "personType" => "0",
            "numItems" => "1"
        ]],
        "dateSelected" => "2018-08-13",
        "additionalInfo" => [[
            "id" => "",
            "bdate" => "",
            "name" => "",
            "hotel" => ""
        ]],
        "temporaryDate" => ""
    ]],
    "state" => " ",
    "localeId" => 2,
    "format" => "",
    "email" => "[email protected]",
    "memberType" => 0,
    "phone" => "930666277",
    "companyName" => "",
    "firstName" => "Tsi Chao ",
    "remarks" => "",
    "memberId" => 321,
    "lastName" => "Yu",
    "address" => "Adress",
    "irs" => ""
];
$request = new Tourboks\Request\OrderCreate([], $body);
$request->setConfig($config);
try {
    $response = $request->perform();
    $data = $response->getData();
} catch (\Tourboks\Exceptions\TourboksResponseException $e) {
    $message = $e->getMessage();
}


$body = [
    "transactionToken" => 987,
    "transactionDate" => "2018-08-01",
];
$requestParameters = [
    'order_id' => 5495,
];
$request = new Tourboks\Request\OrderPay($requestParameters, $body);
$request->setConfig($config);
try {
    $response = $request->perform();
    $data = $response->getData();
} catch (\Tourboks\Exceptions\TourboksResponseException $e) {
    $message = $e->getMessage();
}


$body = [
    "currency" => 'EUR',
    "localeId" => 1,
    "format" => 1,
];
$request = new Tourboks\Request\MyOrders([], $body);
$request->setConfig($config);
try {
    $response = $request->perform();
    $data = $response->getData();
} catch (\Tourboks\Exceptions\TourboksResponseException $e) {
    $message = $e->getMessage();
}