[#481] Capturar datos de reserva de un cliente

Migrated from Redmine #481 | Author: Antonio Cabrera
Status: New | Priority: Low, I can wait | Created: 2020-03-02


Buenas tardes, necesito capturar los datos de una reserva después de que un cliente realice una reserva. Los pasos que estoy siguiendo son:

1.- Hago login para obtener un token: https://user-api.simplybook.me/login
2.- Uso getClientList para obtener el id del usuario a partir de un nombre de cliente. Aquí obtengo este error usando esta petición:

URL: https://user-api.simplybook.me/admin
Headers:
X-Company-Login : dietfarma
X-token : 1392826321383cbb0fbacd2777564a822105e1f3f0023054e757a6e0a56e4c19
Metodo: POST
{“method”:“getClientList”,
“params”:[“anaramirezdf”,null],
“id”:6
}

Obtengo este error:
{
“error”:{
“code”: -32600,
“message”: “Access denied”,
“data”:
},
“id”: “6”
}

I think that I need an admin API-KEY. Could you help me??.

Redmine Admin wrote:

Hi, please check User/Admin API (Company administration service) authorization section here API documentation | SimplyBook.me Online Scheduling
there is no admin token but authorization instead.
You can also use API callback to have your script called each time when new booking appears

Antonio Cabrera wrote:

Redmine Admin wrote:

Hi, please check User/Admin API (Company administration service) authorization section here API documentation | SimplyBook.me Online Scheduling
there is no admin token but authorization instead.
You can also use API callback to have your script called each time when new booking appears

API callback will resolve all my problems. But I have configured that parameter with this value www.dietfarma.com/reserva-confirmada and when a client makes a reservation this URL is not called and my script in this URL is not executed.

Please help me.

Thanks in advance.

Redmine Admin wrote:

it must be called if API plugin is turned on, please check your server logs

Redmine Admin wrote:

I see you have set url https://www.dietfarma.com/reserva-confirmada but it redirects to https://www.dietfarma.com/reserva-confirmada by your server. If redirect is not configured to keep all request data then it will not work. It is better to set API endpoint to url which will not be redirected

Antonio Cabrera wrote:

Redmine Admin wrote:

I see you have set url https://www.dietfarma.com/reserva-confirmada but it redirects to https://www.dietfarma.com/reserva-confirmada by your server. If redirect is not configured to keep all request data then it will not work. It is better to set API endpoint to url which will not be redirected

Sorry for insisting, but I can’t capture the data of a reservation after it will be done. In the URL www.dietfarma.com/reserva-confirmada I have a PHP code to write the result in the log but I don’t get it to work:

$datos = $_POST[“booking_id”];
$datos_reserva = json_decode($datos);
write_log_debug("RESERVA CONFIRMADA: ".$datos_reserva[0]);

When a client makes a new booking this URL(www.dietfarma.com/reserva-confirmada) isn’t called.
How can a get the data of response?.

Please help me. If possible send me some examples. I have read all the documentation but it is not clear to me.

Best regards.

Vitaliy Kordiak wrote:

Hi Antonio,
If I understand your problem correctly, you will need to receive your booking data after the client completes the booking.

You have a Callback URL field in the API custom feature settings. After each reservation you will receive a callback to your url with the following parameters:

booking_id - Booking ID
booking_hash - Booking hash
company - Your company login
notification_type - Notification type. Can be 'create', 'cancel', 'notify', 'change'

For more detail you need to call getBookingDetails (id, sign) API function (API documentation | SimplyBook.me Online Scheduling)

where id is booking_id from callback
sign = md5(bookingId + bookingHash + secretKey) (‘+’ is concatenation)

secretKey - secret key from API custom feature settings


Pay attention! You need to be authorized in API before calling any API function

in JS JSON-RPC lib:

var token = loginClient.getToken(YOUR_COMPANY_LOGIN, YOUR_API_KEY);

or in RAW:

POST /login HTTP/1.1
Host: user-api.simplybook.me
Content-Type: application/json; charset=UTF-8
Accept: application/json

{"jsonrpc":"2.0","method":"getToken","params":[YOUR_COMPANY_LOGIN, YOUR_API_KEY],"id":1}