Publish Users Online (Totalview API)

It is possible to show Totalview users directly on a public website using the Totalview Rest API. This page is intended to help developers and administrators to get it up and running.

License

In order to be able to use this feature, a valid license must be obtained, otherwise, the API will not be accessible. In order to purchase a license, please contact your local sales representative.

Endpoint & Login information

The Totalview Rest API makes use of a public endpoint. Usually, this endpoint is located at tv.[yourdomain.com]:[portnumber]/rest (e.g. tv.frymil.fo:8034/rest). The login information needed to access the API can be found in the WCF Connector settings of the Totalview Admin:

../../_images/Capture.png

Connecting to the API

Using both the endpoint and the login information, you are able to make the initial connection to the Totalview Rest API via the method ‘Userlogin‘. This can be done using any programming language capable of making HTTP Post requests. Below is an example using PHP (and cURL), where we send JSON data in an HTTP Post request to our endpoint URL in order to log in. (Please note that the ‘LoginClient’ should always be ‘4’ in this case)

$url = 'http://tv.frymil.fo:8034/rest/Userlogin';

//Initiate cURL.
$ch = curl_init($url);

//The JSON data.
$jsonData = array(
    'Username' => 'Admin',
    'password' => '*****',
    'LoginClient' => 4
);

//Encode the array into JSON.
$jsonDataEncoded = json_encode($jsonData);

//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);

//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);

//Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

//Execute the request
$result = curl_exec($ch);

The result of a successful call will be a JSON response in the following format:

{
    UserLoginResult: {
        Authenticated: true,
        ErrorMsg: null,
        ServerVersion: "3.3.0.001",
        UserGUID: "aa3bdd7d-34ff-4215-893f-c59e2e684635",
        UserRecID: 0
    }
}

A JSON message containing “Authenticated: true” signifies a sucessful login and will provide a token identifier called UserGUID. This token is meant to be used to retrieve the list of users and their state information.

Retrieving user information

Given the login token from the previous step, it is then possible to get all published users by calling “GetPublishedUsers”:

//Get the userdata using the GUID
$rawdata = file_get_contents(‘http://tv.frymil.fo:8034/rest/GetPublishedUsers?UserGID=”‘. $GUID .‘”&includePictures=false’);

The parameter “includePictures” determines whether or not to include image data for each user. Setting this to “true” will send base64 image strings along with the request.

(Note: For large user databases, donwloading images will drastically increase the filesize of the response. In order to improve performance, server side image caching is recommended!)

The result of a successful call will be a JSON reponse in the following format:

{
    GetPublishedUsersResult: [
    {
        Capabilities: [
            “Accounting”,
            “Bookkeeping”,
            “Financial Management”
        ],
        Divisions: [
            “Administration”
        ],
        ImageData: null,
        StateCaption: “Available”,
        StateColor: {
            B: 0,
            G: 130,
            R: 0
        },
        UserEmail: “john@frymil.fo”,
        UserFirstName: “John”,
        UserLastName: “Petersen”,
        UserLocalPhone: “+45123456789”,
        UserMobilePhone: “+45023456789”
    },…]
}

Publishing Users

You can enable/disable users being shown by going to “Totalview Admin” -> “User” and checking the “Publish User” box.

../../_images/pubuser.png

Managing Published States

In order to hide the internal states for your company, you can set up published states that will be shown instead. This can be done by going to “Totalview Admin” -> “State”. Simply create the new states and make sure that the visibility for all clients is disabled. These can then be assigned to other states by selecting them in the “Published State” dropdown:

../../_images/pubstate-1.png

Troubleshooting

In some cases, there might be problems with firewalls, as they might restrict the traffic to the endpoint. Make sure that all traffic to and from the endpoint over the specified port is allowed.