jsonp with local realtime interface

hi Bart,

Great time at the electro bar camp!

Today i tried to get the jsonp interface working, but i failed to get the same results as you describe in the manual. When i make the following call to the local realtime REST api i do not get the json function name before the json data. In the example in the manual it does. This blocks the option to make a call to the flukso from a webpage served on another web server in my house. Do you have any suggestions what i do wrong?

  1. Mooch-3:~ bram$ curl -v "http://10.0.1.24:8080/sensor/87d2511dfda6c769902d663a653a245d?version=1.0&interval=minute&unit=watt&callback=realtime"
  2. * About to connect() to 10.0.1.24 port 8080 (#0)
  3. *   Trying 10.0.1.24... connected
  4. * Connected to 10.0.1.24 (10.0.1.24) port 8080 (#0)
  5. > GET /sensor/87d2511dfda6c769902d663a653a245d?version=1.0&interval=minute&unit=watt&callback=realtime HTTP/1.1
  6. > User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
  7. > Host: 10.0.1.24:8080
  8. > Accept: */*
  9. >
  10. < HTTP/1.1 200 OK
  11. < Connection: close
  12. < Transfer-Encoding: chunked
  13. < Content-Type: application/json
  14. <
  15. * Closing connection #0
  16. [[1320617737,379],[1320617738,380],[1320617739,380],[1320617740,380],[1320617741,380],[1320617742,382],[1320617743,381],[1320617744,379],[1320617745,381],[1320617746,381],[1320617747,380],[1320617748,380],[1320617749,380],[1320617750,381],[1320617751,381],[1320617752,379],[1320617753,380],[1320617754,377],[1320617755,380],[1320617756,380],[1320617757,380],[1320617758,380],[1320617759,380],[1320617760,380],[1320617761,379],[1320617762,379],[1320617763,378],[1320617764,379],[1320617765,380],[1320617766,379],[1320617767,379],[1320617768,380],[1320617769,379],[1320617770,380],[1320617771,380],[1320617772,380],[1320617773,377],[1320617774,379],[1320617775,379],[1320617776,380],[1320617777,379],[1320617778,380],[1320617779,379],[1320617780,379],[1320617781,380],[1320617782,376],[1320617783,379],[1320617784,379],[1320617785,379],[1320617786,379],[1320617787,379],[1320617788,379],[1320617789,379],[1320617790,379],[1320617791,378],[1320617792,381],[1320617793,379],[1320617794,378],[1320617795,378],[1320617796,379]]

Best regards,
Bram

icarus75's picture

Hi Bram,

Elektro:camp was a pure hacker's fest once more! Still digesting all of the ideas and discussions that took place.

As for the jsonp callback functionality: my bad. I have only recently made some changes to the api. You can look up commits a8a9a99e3f, f917d220cf and af3a499582 in the develop branch of flm02 [1]. These changes haven't made it into a release yet. I would suggest that you just overwrite the /usr/bin/restful script in the Fluksometer with the latest restful.lua version in develop. Make sure the script has 755 permissions and loses the '.lua' extension when copied over.

[1]: https://github.com/flukso/flm02/commits/develop

Cheers,
Bart.

wombach's picture

Hi,

the url provided by Bram returns 60 measurements, which are the 60 measurements of the last minute. Toke a while for me to figure this out.

Andreas