...
All entity-level operations through the SDK require entity authentication. This is done via theĀ rs.sdk.core.login()
function.
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">
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);
});
}
else
// Assumes a loginID and password have already been saved 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> |
...
Code Block |
---|
|
<!--rs.sdk:consents-->
<ul style="list-style: none">
<li>
<input id="C-`consent{consent.id`id}" type="checkbox">
<label for="C-`consent{consent.id`">`consent.name`<id}">{consent.name}</label>
</li>
<li>
<input id="C-`consent{consent.id`id}" type="checkbox">
<label for="C-`consent{consent.id`">`consent.name`<id}">{consent.name}</label>
</li>
</ul> |
Code Block |
---|
|
<!--rs.sdk:accept:Do you accept these terms?-->
<button onclick="this.disabled = true;...(process consents and perform acceptance)...">
Do you accept these terms?
</button> |
...