Följ

API:Web

The Exor Live client-side API is an easy-to-use API that enables rich integration with Exor Live using only client-side technologies.

This means that there is no need to use server-side webservice calls, store credentials or foreign keys.

 

Changelog

If you are looking for the previous version of the documentation, then it can be found here.

04.07.2011
Initial version
01.11.2011
Support for OAuth and the new `data` api added.

 

Requirements/Support

Registration

The domain of the application is used to identify it, and so this must be registered in order for the API to function. For development purposes the `localhost` domain has also been whitelisted and so you can test using this domain.

Contact ExorLive to register your application.

Authorization

Exor Live uses OAuth2 to provide its users to authorize third-party applications. If you need to use more than the ExorLive.app methods, you need to obtain a valid OAuth Access Token. This must be done with serverside code.

Javascript API

For easy integration we provide you with a Javascript library exposing most of ExorLive's functionality in an easy way. This allows for flexible integration between ExorLive and other single-page applications.

To use this, add the following code to your document:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// This will be called once the the Exor Live framework is ready
function init_ExorLive() {
     
    // The two following events MUST be handled in order to complete the OAuth flow
    // This data is easily obtained serverside with not need of a library and with very little code
    // In this example 'PageMethods.RequestAccessToken' is an AJAX method calling back to the server
    ExorLive.Events.on("access.code", function (code) {
        // We pass the Grant Token to the backend so that it can exchange this for an AccessToken
        PageMethods.RequestAccessToken(code, function (accessToken) {
            // Once obtained, update the API with the new token
            ExorLive.setAccessToken(accessToken);
        });
    });
 
    ExorLive.Events.on("access.expired", function () {
        // passing "" instead of the Grant Token signals to the backend that we want to refresh the existing token
        PageMethods.RequestAccessToken("", function (accessToken) {
            // Once obtained, update the API with the new token
            ExorLive.setAccessToken(accessToken);
        });
    });
 
    // Respond to default events from the API
    ExorLive.Events.on("access.missing", function (err) {
        var el = document.getElementById("divUserProfile");
        // Display a default Authorize widget
        el.innerHTML = " <div class=\"el-widget\" data-type=\"Authorize\" data-scope=\"read_profile read_workout\">Authorize</div>";
        ExorLive.ui.widgets.parse(el);
    });
 
    ExorLive.Events.on("auth.success", function (profile) {
        // Display the profile data returned from Exor Live
        document.getElementById("divUserProfile").innerHTML = "Navn: " + profile.Firstname + " " + profile.Lastname + "<br/>" + "Email: " + profile.Email;
    });
 
     
     
    // This is where you configure the API
    ExorLive.init({
        // The culture you want used
        culture: "en-US",
        // Your ExorLive Applications identifier
        clientId: "testkey",
        // In case the user needs to create an account, this will be used to populate the needed fields
        orderData: { //
            firstName: "john",
            lastName: "doe",
            email: "user@domain.example"
        },
        // If the user has already autorized you, then you can supply the token here
        accessToken: {
            // The token string
            AccessToken: "...................",
            // ISO8601 using UTC
            Expiration: "2011-09-21 12:33:10",
            // The scopes authorized through this token. This will help the API give proper feedback.
            Scope: "read_profile read_workouts ...."
        },
        // Whether the API should look for, and instantiate ExorLive Widgets
        parse: true
    });
}

and include the following script

1
<script src="https://exorlive.com/api/bootstrapper.ashx" type="text/javascript"></script>

The document is now properly set up to provide the the user with a rich experience.

Doctype

For reliable behavior, it is important that your document brings the browser into standards mode, preferably by using a valid doctype like

1
2
3
<!doctype HTML>
<html>
...

Supported browsers

This API supports all modern browsers as well as IE6 and IE7.

How to use it

The ExorLive Javascript API provides three levels of integration

  • 'Remote control' - the ability to interact with, and to instruct the ExorLive Webapplication
  • Data API - an api providing access to the same underlying infrastructure that the ExorLive Webapplication does
  • Widget API - an api providing easy access to render prebuilt widgets showing data from ExorLive

All levels of integration requires that the user authorize you application with the appropriate scopes.

Premade Projects

We have a few premade project which you can use. The examples are Visual Studio 2010 projects and uses C#.

Full API example. This one requires registration and server side code.

Client side only example. This uses only HTML and javascript, and no authorization necessary. You will need to run this from a webserver (localhost or 127.0.0.1). If you run it as a file, the javascript will NOT run.