The SDK is a JavaScript/ECMAScript library built to facilitate front-end interactions with the Rubiq API. It uses the standard JavaScript Authenticating from JavaScript which authentication which means that the requesting domain must be registered in dialogportal™. Contact a Fluid Account Manager for assistance with this.
The SDK is comprised of a number of scripts. core.js
is always required but the others are optional - include the ones you need.
Note |
---|
The SDK uses |
Note |
---|
The SDK is ECMAScript5 (ES5) compatible, which means it supports most browsers. If you need to support legacy browsers, you may need to include compatibility shims such as es5-shim and json3, which together support all SDK requirements. |
...
Code Block | ||
---|---|---|
| ||
<script src="https://api.dialogportal.com/v1/sdk/v1/core.js"></script> <script src="https://api.dialogportal.com/v1/sdk/v1/entity.js"></script> <script type="text/javascript"> var APP_KEY = 12345; rs.sdk.core.init(APP_KEY, function() { // Check whether an entity is already logged in if (rs.sdk.core.getEntityID() !== -1) { console.debug('entityID from localStorage: ', rs.sdk.core.getEntityID()); rs.sdk.entity.get(function(e) { console.debug('Entity fetched. Name:', e.firstName, e.lastName, '[' + e.email + ']'); }); } else // Assumes avariables loginID and password have already been savedpopulated to variables rs.sdk.core.login(loginID, password, loginSuccess, loginError); }); function loginSuccess(data) { console.debug('Entity authenticated: ', rs.sdk.core.getEntityID()); console.debug('Name: ', data.firstName, data.lastName); } function loginError(err) { console.error('Login failed: ' +, err.responseText); } </script> |
...
If a login error occurred (e.g. wrong loginID or password), the login error callback function (loginError()
) is called, which loggs logs the error to the error console - in a real scenario this error message would be displayed to the user somehow.
...