This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Remote control of Philips TV with json
#3
After a long session with Wireshark I gave up on this script...

I now use the following script which works:


Code:
require('json')
require('socket.url')
require('socket.http')
local ltn12 = require("ltn12")

path = "http://192.168.0.232:1925/1/input/key"
local payload = [[{"key" : "CursorLeft"}]]
print(payload)
local response_body = { }
local res, code, response_headers, status = socket.http.request
 {
   url = path,
   method = "POST",
   headers =
   {
         ["Content-Type"] = "application/json",
         ["Content-Length"] = payload:len()
   },
  source = ltn12.source.string(payload),
   sink = ltn12.sink.table(response_body)
 }

print('Response: = ' .. table.concat(response_body) .. ' code = ' .. code .. '   status = ' .. status,1,'Sample POST request with JSON data',-1)
Reply


Messages In This Thread
RE: Remote control of Philips TV with json - by baggins - 30.12.2016, 10:21

Forum Jump: