Support


Contact us if you have any questions and we'll help you

Calling Api methods

Hello, i'm trying to use the api, for every request i get the same reponse.
This is one example of request
url: https://panel.cloudhotelier.com/api
Post with the json
{
"request" :
{
"app": "Appid",
"secret": "Token",
"log": 153139435922.59,
"task": "inventory_get",
"data": {}
}
}

I always get the same response
{
"request": null,
"response": "HRS Manager Api",
"errors": {
"errors": [],
"warnings": [],
"notices": []
}
}

What am i missing?

Thanks


Notifications

Comments

Xavier Pallicer   July 13, 2018

Please note the JSON must be sent in a post with a variable called "request", take a look:

https://github.com/cloudhotelier/api/blob/master/basics.md

Regards!

Lucas January 28, 2019   The documentation was deleted  
Reply

Gard   July 17, 2018

Hello again
i'am using post and the json has a request.

POST /api/ HTTP/1.1
Host: panel.cloudhotelier.com/api/
Content-Type: application/json
{
"request" :
{
"app": "appid",
"secret": "appsecret",
"log": 153139435822.59,
"task": "inventory_get",
"data": {}
}
}

do you see anything wrong on the request?

Reply

Xavier Pallicer   July 18, 2018

Please take a look at our docs:

// build the request data
$request = (object)[
  'app' => 12345,
  'secret' => 'YOURAPPSECRETKEY',
  'log' => microtime(true) * 100,
  'task' => 'booking_get',
  'data' => (object)['booking_id'=>123456]
];

// curl POST
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://panel.cloudhotelier.com/api');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['request' => json_encode($request)]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$api_response = curl_exec($ch);
curl_close ($ch);

The important part is this one:
`LOPT_POSTFIELDS, http_build_query(['request' => json_encode($request)]));``

request is a post field containing json encoded data. If you show us the rest of the code you'll get better help..

Reply