Post JSON data here to get room price and availability.
See here for information about using the JSON API.
Note, this function uses API JSON V1 apikey and propkey for authentication as per other JSON functions, not the OTA channel password.
{ "authentication": { "apiKey": "apiKeyAsSetInAccountSettings", "propKey": "propKeyAsSetForTheProperty" }, "roomId": 12345, "from": "20241122", "to": "20241221" }
Field | Description | Data Type | Required | Notes |
---|---|---|---|---|
apiKey | apiKey for account | string | required | |
propKey | propKey for property | string | required | |
roomId | room id for room | integer | required | |
from | from date | date (yyyymmdd) | optional | default=today |
to | to date | date (yyyymmdd) | optional | default=+30 days |
Response is an array of date objects for the OTA channel with the following elements
Field | Description | Data Type | ||
---|---|---|---|---|
i | inventory | int | number of units available for booking | |
r | rates | object | rates are further grouped into objects by their ratecodes | |
p1 - pN | prices for the specified occupancy | number | for example p2 is a price for up to 2 people | |
m | minimum stay | int | ||
mx | maximum stay | int | ||
r | restriction type | int | 0=stay through, 1=first night, 2=gap filler | |
c | closed | int | 0=rate open, 1=rate closed | |
ci | checkin allowed | int | 0=no, 1=yes | |
co | checkout allowed | int | 0=no, 1=yes |
<?php /* * The following sample uses a PHP array to construct the JSON data and php-curl to post it to the API. * This sample will get one room with the specified parameters. * Change the parameters to values for your account. */ $auth = array(); $auth['apiKey'] = 'apiKeyAsSetInAccountSettings'; $auth['propKey'] = 'propKeyAsSetForTheProperty'; $data = array(); $data['authentication'] = $auth; $data['roomId'] = 12345; $data['from'] = date('Ymd', strtotime('+1 day')); $data['to'] = date('Ymd', strtotime('+30 days')); $json = json_encode($data); $url = "http://soft.4twa.com/api/ota/JSON_HotelAvail"; $ch=curl_init(); curl_setopt($ch, CURLOPT_POST, 1) ; curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); $result = curl_exec($ch); curl_close ($ch); echo $result; ?>