Hello,
I want integrate with Traccer server. This server give the JSON when I log in and brows such address:
http://demo.traccar.org/api/positions/
But for LM communication I must have some authorisation. What should I add to this script?
Now it gives:
Login is an email so it has '@'.
	
	
	
I want integrate with Traccer server. This server give the JSON when I log in and brows such address:
http://demo.traccar.org/api/positions/
But for LM communication I must have some authorisation. What should I add to this script?
Code:
-- load required modules
http = require("socket.http")
mime = require("mime")
-- Alternatively, one could fill the appropriate header and authenticate
-- the request directly.
r, c, d, e = http.request {
  url = "http://demo.traccar.org/api/positions/",
  headers = { authorization = "Basic " .. (mime.b64("login:password")) }
}
log(r,c,d,e)Code:
* arg: 1
  * number: 1
* arg: 2
  * number: 200
* arg: 3
  * table:
   [server]
    * string: Jetty(9.2.19.v20160908)
   [content-type]
    * string: application/json
   [connection]
    * string: close
   [content-length]
    * string: 393
   [access-control-allow-headers]
    * string: origin, content-type, accept, authorization
   [access-control-allow-origin]
    * string: *
   [date]
    * string: Sat, 29 Oct 2016 22:39:46 GMT
   [access-control-allow-credentials]
    * string: true
   [access-control-allow-methods]
    * string: GET, POST, PUT, DELETE, OPTIONS
* arg: 4
  * string: HTTP/1.1 200 OK
[b]Traccar[/b] 30.10.2016 00:39:27
* arg: 1
  * number: 1
* arg: 2
  * number: 200
* arg: 3
  * table:
   [server]
    * string: Jetty(9.2.19.v20160908)
   [content-type]
    * string: application/json
   [connection]
    * string: close
   [content-length]
    * string: 393
   [access-control-allow-headers]
    * string: origin, content-type, accept, authorization
   [access-control-allow-origin]
    * string: *
   [date]
    * string: Sat, 29 Oct 2016 22:39:27 GMT
   [access-control-allow-credentials]
    * string: true
   [access-control-allow-methods]
    * string: GET, POST, PUT, DELETE, OPTIONS
* arg: 4
  * string: HTTP/1.1 200 OKLogin is an email so it has '@'.
 
 

 

 
	
 
	