Manual

Communication type

Previo XML is based on XML messages sent through HTTP. Each function (returning rates, rooms, etc.) has it's unique URL which needs to be called.

You can call the function using it's parameters and wraping it within <request> element. Resulting XML document must be sent using POST method to the URL of the function. The response from our server will be again an XML document bearing output of the function.

Calling Hotel.get in PHP

PHP offers several methods how to send POST data to a specified URL.

<?php
$login    = '*****';
$password = '*****';

$request =
    '<?xml version="1.0"?>' . "\n" .
    '<request>' .
    '<login>' . htmlspecialchars($login) . '</login>' .
    '<password>' . htmlspecialchars($password) . '</password>' .
    '<hotId>1</hotId>' .
    '</request>';

$context = stream_context_create(array(
    'http' => array(
    'method'  => 'POST',
    'header'  => 'Content-Type: application/xml',
    'content' => $request)));

$response = file_get_contents(
    'https://api.previo.cz/x1/hotel/get', null, $context);

echo "<pre>\n";
echo htmlspecialchars($response);
echo "</pre>";
<?php
$login    = '*****';
$password = '*****';
 
$request =
	'<?xml version="1.0"?>' . "\n" .
	'<request>' .
	    '<login>' . htmlspecialchars($login) . '</login>' .
	    '<password>' . htmlspecialchars($password) . '</password>' .
	    '<hotId>1</hotId>' .
	'</request>';
 
$ch = curl_init('https://api.previo.cz/x1/hotel/get');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
$response = curl_exec($ch);
 
echo "<pre>\n";
echo htmlspecialchars($response);
echo "</pre>";

Use curl if your server doesn't allow allow_url_fopen. On the other hand if curl is missing try file_get_contents.

URL addresses

Basic URL of Previo XML is:

https://api.previo.cz/x1/

 

URL of concrete function is constructed from its name, replacing the dot with slash, lowering the first letter and addind this to the end of the URL. Examples:

  • Hotel.get => https://api.previo.cz/x1/hotel/get
  • System.getCountries => https://api.previo.cz/x1/system/getCountries

Login credentials

Each function requires elements login and password. Without them it ends with error message. If you don't have your login credentials yet please contact us.

Errors

Calling API function might fail. There might be an error in Previo API or in your parameters. In case of an error our servers return this instead of the expected document:

<error>
    <code>error_code</code>
    <message>error_description</message>
</error>

List of all error codes and messages.

In most serious cases our server may response with HTTP 500 or not response at all. Don't forget to work around these situations in your code as well.

List of functions

All available functions can be found in the Function list in the left menu.