User API guide: Difference between revisions
No edit summary |
No edit summary |
||
| Line 9: | Line 9: | ||
='''AUTHORIZATION'''= | ='''AUTHORIZATION'''= | ||
<br><br> | <br><br> | ||
Using Simplybook API methods require an authentication. To authorize in Simplybook API you need to get an access key — access-token. In order to get this access-token you should call the JSON-RPC method getToken on | Using Simplybook API methods require an authentication. To authorize in Simplybook API you need to get an access key — access-token. In order to get this access-token you should call the JSON-RPC method getToken on https://user-api.simplybook.me/login service passing your personal API-key. You can copy your API-key at admin interface: go to the 'Custom Features' link and select API Custom Feature 'Settings'. Then you have to init remote access to Simplybook API. Your request should contain the following headers: 'X-Company-Login', 'X-Token'. | ||
Getting the access-token can be implemented either from client side or from your server which is the more secure solution. | Getting the access-token can be implemented either from client side or from your server which is the more secure solution. | ||
| Line 25: | Line 25: | ||
<br><br> | <br><br> | ||
<nowiki>var loginClient = new JSONRpcClient({ | <nowiki>var loginClient = new JSONRpcClient({ | ||
'url': ' | 'url': 'https://user-api.simplybook.me' + '/login', | ||
'onerror': function (error) {}, | 'onerror': function (error) {}, | ||
}); | }); | ||
| Line 33: | Line 33: | ||
<br><br> | <br><br> | ||
<nowiki>this.client = new JSONRpcClient({ | <nowiki>this.client = new JSONRpcClient({ | ||
'url': ' | 'url': 'https://user-api.simplybook.me', | ||
'headers': { | 'headers': { | ||
'X-Company-Login': YOUR_COMPANY_LOGIN, | 'X-Company-Login': YOUR_COMPANY_LOGIN, | ||
| Line 44: | Line 44: | ||
<br><br> | <br><br> | ||
'''Getting the token-key.'''<br><br> | '''Getting the token-key.'''<br><br> | ||
<nowiki>$loginClient = new JsonRpcClient(' | <nowiki>$loginClient = new JsonRpcClient('https://user-api.simplybook.me' . '/login/'); | ||
$token = $loginClient->getToken(YOUR_COMPANY_LOGIN, YOUR_API_KEY);</nowiki> | $token = $loginClient->getToken(YOUR_COMPANY_LOGIN, YOUR_API_KEY);</nowiki> | ||
<br><br> | <br><br> | ||
'''Initialization JSON-RPC-client.''' | '''Initialization JSON-RPC-client.''' | ||
<br><br> | <br><br> | ||
<nowiki>$client = new JsonRpcClient(' | <nowiki>$client = new JsonRpcClient('https://user-api.simplybook.me' . '/', array( | ||
'headers' => array( | 'headers' => array( | ||
'X-Company-Login: ' . YOUR_COMPANY_LOGIN, | 'X-Company-Login: ' . YOUR_COMPANY_LOGIN, | ||
| Line 63: | Line 63: | ||
<br><br> | <br><br> | ||
<nowiki>var loginClient = new JSONRpcClient({ | <nowiki>var loginClient = new JSONRpcClient({ | ||
'url': ' | 'url': 'https://user-api.simplybook.me' + '/login', | ||
'onerror': function (error) {}, | 'onerror': function (error) {}, | ||
}); | }); | ||
| Line 71: | Line 71: | ||
<br><br> | <br><br> | ||
<nowiki>this.client = new JSONRpcClient({ | <nowiki>this.client = new JSONRpcClient({ | ||
'url': ' | 'url': 'https://user-api.simplybook.me' + '/admin/', | ||
'headers': { | 'headers': { | ||
'X-Company-Login': YOUR_COMPANY_LOGIN, | 'X-Company-Login': YOUR_COMPANY_LOGIN, | ||
| Line 83: | Line 83: | ||
'''Getting the token-key.''' | '''Getting the token-key.''' | ||
<br><br> | <br><br> | ||
<nowiki>$loginClient = new JsonRpcClient(' | <nowiki>$loginClient = new JsonRpcClient('https://user-api.simplybook.me' . '/login/'); | ||
$token = $loginClient->getUserToken(YOUR_COMPANY_LOGIN, YOUR_USER_LOGIN, YOUR_USER_PASSWORD);</nowiki> | $token = $loginClient->getUserToken(YOUR_COMPANY_LOGIN, YOUR_USER_LOGIN, YOUR_USER_PASSWORD);</nowiki> | ||
<br><br> | <br><br> | ||
'''Initialization JSON-RPC-client.''' | '''Initialization JSON-RPC-client.''' | ||
<br><br> | <br><br> | ||
<nowiki>$client = new JsonRpcClient(' | <nowiki>$client = new JsonRpcClient('https://user-api.simplybook.me' . '/admin/', array( | ||
'headers' => array( | 'headers' => array( | ||
'X-Company-Login: ' . YOUR_COMPANY_LOGIN, | 'X-Company-Login: ' . YOUR_COMPANY_LOGIN, | ||