1

Create locator URL using Javacript API

(edited by orlo_26 18/05/2019 08:14:27)

Topic: Create locator URL using Javacript API

Hi Everyone! smile

Im having problems trying to create a locator URL using Javascript API. There are a couple of similar questions on this forum, but they use Remote API... I need the solution for Javascript API.

This is what I have:

 // get instance of current Session
var sess = wialon.core.Session.getInstance();          

//Creating the token object
 var token = {
                userId : null,
                h : null,
                app : "testApp",
                at : 0,
                dur : 3600,
                fl : 256,
                p : "",
                items : [18416637]
 };

//Creating the token
sess.updateToken("create",token,
                             function (code) { // login callback
                if (code){ msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code
 });

This is all I have... and Im getting an error code 4 (Invalid Input)

The documentation Im using: https://sdk.wialon.com/api/index.html#w … hod_public

I really need help on this. Thanks in advice!

2

Create locator URL using Javacript API

(edited by soporte3 19/05/2019 02:15:06)

Re: Create locator URL using Javacript API

orlo_26
Try removing h param, and try adding this to the p param:
"{\"note\":\"\",\"zones\":0,\"tracks\":0}"

Also try changing the app name to "locator", and now you should have a response to use it in your callback(code,data)

3

Create locator URL using Javacript API

(edited by orlo_26 19/05/2019 20:31:06)

Re: Create locator URL using Javacript API

soporte3

Thanks so much for your help. It worked and token is being created succesflly.

But now for some reason the sess.updateToken(); is not returning the new token I just created. Do you know how I can get back the token I just created?

Thanks in advice!

4

Create locator URL using Javacript API

(edited by soporte3 19/05/2019 22:34:41)

Re: Create locator URL using Javacript API

almost every function from the sdk uses a callback with 2 pams, code and data. after you validate code to be 0, you must get the token from data, it comes in the h param, so you should get it as data.h

5

Create locator URL using Javacript API

Re: Create locator URL using Javacript API

Thanks so much! it really helped me. smile

-Orlando