PHP code example of maxkut / tourvisor

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

    

maxkut / tourvisor example snippets


use Tourvisor\Tourvisor;
use Tourvisor\Client;

// создаем объект ядра библиотеки с http клиентом
$tourvisor = new Tourvisor(new Client('[email protected]', 'password'));
// ...

use Tourvisor\Requests\SearchRequest;

// ... $tourvisor ...

$searchRequest = new SearchRequest();
$searchRequest->country = 30;
$searchRequest->departure = 1;
// остальные параметры можно узнать в docBlock класса запроса

$result = $tourvisor->getResult($searchRequest); 
// В ответ придет идентификатор запроса, например 1015951847

use Tourvisor\Requests\SearchResultRequest;

// ... $tourvisor ...

$searchResultRequest = new SearchResultRequest();
// передаем обязательный параметр - идентификатор запроса
$searchResultRequest->requestid = 1015951847;

$result = $tourvisor->getResult($searchResultRequest);

    /**
     * @param \Tourvisor\Tourvisor $tourvisor
     * @param \Tourvisor\Requests\HotToursRequest $hotToursRequest
     * @throws \Tourvisor\Exceptions\AuthorizeException
     * @throws \Tourvisor\Exceptions\HasEmptyRequiredParamsException
     * @throws \Tourvisor\Exceptions\ResponseException
     */
    public function index(\Tourvisor\Tourvisor $tourvisor, \Tourvisor\Requests\HotToursRequest $hotToursRequest)
    {
        $hotToursRequest->items = 10;
        $hotToursRequest->city = 1;
        
        $result = $tourvisor->getResult($hotToursRequest);
        
        return response($result);
    }

$tourvisor = app('tourvisor');
// или
$tourvisor = app()->make('tourvisor');

// ... сформировали $searchRequest

$result = \Tourvisor::getResult($searchRequest);