Clearly I need a REST
As an Accidental Programmer I sometimes run across a problem that requires knowledge, rather than brute force, and I think this is one of those times.
I have one of the little Roku media streamers, which has external control support (found here):
http://sdkdocs.roku.com/display/sdkdoc/External+Control+Guide
I can establish a connection with my master on the correct port, but I just can't get my commands acted upon. I've tried various iterations of what's in the examples, but it seems (for example) a Home button emulation should be sent as (after a successful connection) POST /keypress/Home
At least I think so. If anyone can offer an educated opinion as to how the string needs to actually be formatted I'd appreciate it. All the online help examples involve various.cryptic.libraries that I don't have the depth to understand.
I have one of the little Roku media streamers, which has external control support (found here):
http://sdkdocs.roku.com/display/sdkdoc/External+Control+Guide
I can establish a connection with my master on the correct port, but I just can't get my commands acted upon. I've tried various iterations of what's in the examples, but it seems (for example) a Home button emulation should be sent as (after a successful connection) POST /keypress/Home
At least I think so. If anyone can offer an educated opinion as to how the string needs to actually be formatted I'd appreciate it. All the online help examples involve various.cryptic.libraries that I don't have the depth to understand.
0
Comments
Can you post the code with your string build too? Might help.
E
DEFINE_DEVICE dvRoku = 0:3:0 vdvRoku = 33001:1:0 DEFINE_EVENT DATA_EVENT [dvRoku] { ONLINE: SEND_STRING dvRoku, 'POST /keypress/Home' // 'POST /keypress/Home HTTP/1.1' } CHANNEL_EVENT [vdvRoku,1] { ON: IP_CLIENT_OPEN (dvRoku.Port,'192.168.1.20',8060,1) }Thanks! I have the Roku up on the TV and I'm not on the Home screen, so I would know if this command worked.
DEFINE_FUNCTION AddHTTPGet(CHAR cShortURI[]) { //---Add an HTTP GET request to BBox.Comm.cQue //---To be instantiated by SendQue above STACK_VAR CHAR cURLString[512] STACK_VAR CHAR cHeader[512] cURLString = "'/',cShortURI" DebugString(4,"'Add to Que: HTTP://',BBox.Comm.cIPAddress,cURLString") cHeader = "'GET ',cURLString,' HTTP/1.1',$0D,$0A" cHeader = "cHeader,'Host: ',BBox.Comm.cIPAddress,$0D,$0A" cHeader = "cHeader,'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64,rv:13.0) Gecko/20100101 Firefox/13.0.1',$0D,$0A" cHeader = "cHeader,'Accept: text/html,application/xhtml+xml,application/xml;q=0.9*/*;q=0.8',$0D,$0A" cHeader = "cHeader,'Accept-Language: en-us;q=0.5',$0D,$0A" cHeader = "cHeader,'Accept-Encoding: gzip,deflate',$0D,$0A" cHeader = "cHeader,'Connection: keep-alive',$0D,$0A,$0D,$0A" BBox.Comm.cQue = "BBox.Comm.cQue,cHeader,$0B,$0B" DebugString(3,"'AddHTTPGet : ',cShortURI") }You can find the entire module here: https://github.com/nickmil/BoxeeBox
As you can see, there is a lot of information required of an HTTP header. A tool that will come in quite handy as you play more with RESTful APIs is the POSTman REST client. It's a Chrome app that breaks down everything that happens in a REST request and response.
I replaced your GET with POST in the function and gave it a try with my Home command and it worked, thanks. I guess the Roku document assumes a level of http/REST knowledge that I don't have.
Cheers!
Agreed. There is a lot of header information that typically isn't needed in the scope of devices/services we are communicating with.