Forum Discussion

bryanharley's avatar
11 years ago

PHP cURL script to control Roku box not working

I was reading here about the RESTful service accessed via the http protocol on port 8060. They provide command line curl examples, like:

$ curl -d '' http://192.168.1.134:8060/keypress/home


I need to write this as a PHP script that will execute a series of actions (all require just a POST request): keypress/home, launch/appid, keypress/select, keypress/right, keypress/right, keypress/select.

See below for what I came up with for one command. Two questions:

1) My Roku is not responding to this, so what am I doing wrong?
2) What's the best way to send multiple POST requests one after the other?


<?php
$ch = curl_init('http://192.168.1.134:8060/keypress/home');
$data = '';

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '$data');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);
?>

12 Replies