if (!isset($payload['service'])) { $response['error'] = 'SERVICE_MISSING'; } elseif (!isset($payload['method'])) { $response['error'] = 'METHOD_MISSING'; } elseif (!isset($payload['parameters'])) { $response['error'] = 'PARAMETERS_MISSING'; } else { # Include BoxeeBoxPHPJSONRPC class require_once '../BoxeeBoxPHPJSONRPC.class.php'; # Attempt to execute try { # Connect to BoxeeBox $bb = new BoxeeBoxPHPJSONRPC($payload['hostname']); # Restore pre-existing sessions if ($payload['deviceid'] != 'null') { $bb->Device('Connect', $payload['deviceid']); } # Execute JSONRPC API Query array_unshift($payload['parameters'], $payload['method']); $output = call_user_func_array(array($bb, $payload['service']), $payload['parameters']); } catch (Exception $error) { $output = 'CONNECTION ERROR'; } } } else { $response['error'] = 'PAYLOAD_MISSING'; } # Return output die($output); } /************************************************
<?php /* * File: keypress.php * Description: jQuery KeyPress Example * Author: Nicholas Robinson 11/19/2011 */ # Include BoxeeBoxPHPJSONRPC class require_once '../BoxeeBoxPHPJSONRPC.class.php'; # Handle specified action if (isset($_REQUEST['action']) && isset($_REQUEST['hostname']) && isset($_REQUEST['deviceid'])) { # Catch Exceptions try { # Connect to BoxeeBox $bb = new BoxeeBoxPHPJSONRPC($_REQUEST['hostname']); $bb->Device('Connect', $_REQUEST['deviceid']); # Extract action $action = $_REQUEST['action']; # Extract url (if set) $value = isset($_REQUEST['value']) ? $_REQUEST['value'] : ''; # Call appropriate API method switch ($action) { case 'Home': $bb->Input('Home'); break; case 'MouseClick': $bb->Input('MouseClick'); break; case 'Back': $bb->Input('Back'); break;