[#323] API method getClientList does not work

Migrated from Redmine #323 | Author: Ahmed Hassan
Status: New | Priority: Immediate, there is BUG! | Created: 2019-01-30


Hello,
here is a link to the docs

I am trying to send API request using the next code

try {
$loginClient = new JsonRpcClient(‘https://user-api.simplybook.it’ . ‘/login/’);
$token = $loginClient->getToken(‘pathtoarabiccom’, ‘babdb8e53e8f8084a178fec1ecb4f78b0b0bb090b06cbc590d2fa6cc5936c8b3’);
$api = new JsonRpcClient(‘https://user-api.simplybook.it’ . ‘/’, array(
‘headers’ => array(
'X-Company-Login: ’ . ‘pathtoarabiccom’,
'X-Token: ’ . $token
)
));
} catch (Exception $e) {
echo $e;die;
return false;
}

print_r($api->getClientList()); die;

And it is producing the next error

Fatal error: Uncaught Exception: Request error: Method not found in C:\amembersvn\test.php:54
Stack trace:
#0 C:\amembersvn\test.php(75): JsonRpcClient->__call(‘getClientList’, Array)
#1 {main}
thrown in C:\amembersvn\test.php on line 54

Is that API method working?
Or am I doing something wrong

Redmine Admin wrote:

this is admin API method, but you are using public API
Please follow this instructions API documentation | SimplyBook.me Online Scheduling to use admin API

Ahmed Hassan wrote:

Here is the new code accoring to the docs

try {
$loginClient = new JsonRpcClient(‘https://user-api.simplybook.it’ . ‘/login/’);
$token = $loginClient->getUserToken(‘pathtoarabiccom’, ‘amember’, ‘ax#Fr586’);
$api = new JsonRpcClient(‘https://user-api.simplybook.it’ . ‘/admin/’, array(
‘headers’ => array(
'X-Company-Login: ’ . ‘pathtoarabiccom’,
'X-Token: ’ . $token
)
));
} catch (Exception $e) {
echo $e;die;
return false;
}

print_r($api->getClientList()); die;

and error is

Fatal error: Uncaught Exception: Request error: Access denied in C:\amembersvn\test.php:54
Stack trace:
#0 C:\amembersvn\test.php(89): JsonRpcClient->__call(‘getClientList’, Array)
#1 {main}
thrown in C:\amembersvn\test.php on line 54

Redmine Admin wrote:

it supposed to be X-User-token header. Please read instructions by the link above

Ahmed Hassan wrote:

The question is about API documentation | SimplyBook.me Online Scheduling - does it require client hash for “sign” parameter?
What can be done if we have only client ID?
I mean is that possible to get client hash from client ID ?

Redmine Admin wrote:

if you don’t have sign then you can use API documentation | SimplyBook.me Online Scheduling and provide client_id as filter

Ahmed Hassan wrote:

I send “cancelBooking” reques and get true as a result. Also I see booking was canceled in the backend but Simplybook does not send notification to notification url. IS that expected?

Dmytro Bondarev wrote:

you should receive cancel notifications, unless it was cancelled before.
also make sure that this booking was confirmed.

Ahmed Hassan wrote:

Is that somehow possible to sign in user into the Simplybook widget with exact client ID ? Currently I am using “predefined” but Simplybook is creaeting new user(with the same email address ) for new booking. And that is a big problem.

Ahmed Hassan wrote:

For example currently there are 3 users with the same name, email and phone
Array
(
[0] => stdClass Object
(
[id] => 31
[name] => anton orlov
[phone] => +18005555555
[email] => anton.orloff@cgi-central.net
)

[1] => stdClass Object
    (
        [id] => 35
        [name] => anton orlov
        [phone] => +18005555555
        [email] => anton.orloff@cgi-central.net
    )

[2] => stdClass Object
    (
        [id] => 37
        [name] => anton orlov
        [phone] => +18005555555
        [email] => anton.orloff@cgi-central.net
    )

)
Is that possible to oprevent duplicate users?

Redmine Admin wrote:

yes, you can use Client login feature

Ahmed Hassan wrote:

How do I use CLient login feature with widget code?

Redmine Admin wrote:

There is support of this feature in widget.

Ahmed Hassan wrote:

Where can I read about how to use it?

Ahmed Hassan wrote:

How do I pass client ID to the widget?
I only see docs Widgets for your own website - Widgets for your own website - SimplyBook.me and it does not explain that.

Redmine Admin wrote:

there is no way to pass ID to widget. And this cannot be done for security reasons because it is very simple for attacker to pass some ID and got access to client’s data

Ahmed Hassan wrote:

So simplybook will add new user for each new load of widget and new booking each time and that cannot be prevented?

Redmine Admin wrote:

You can enable client login feature to prevent this

Ahmed Hassan wrote:

We need to prevent double login. Maybe that is possible to somehow sign in customer (we alreadt have login/password_ and send session id or cookie to the widget?

Redmine Admin wrote:

This is not secure way and not possible for now.