Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
<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);
         });
      }
      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>

...