API

This sections demonstrates the use of the API interface to communicate directly with supported devices.

Request Parameter

The POST_DEVICE_CMD parameter is used to send commands directly to device.

Request = POST_DEVICE_CMD

Parameters

Description

device_serial_id

Serial number of the device .

cmd

Command to control device. SUPPORTED COMMANDS (STOP,START,PLAY,PLAY_STOP)


Example usage :

<?php 


/**
 * Zerhex Sample API Call
 *
 * @package    Zerhex Digital
 * @author     Zerhex <developer@zerhex.com>
 * @copyright  Copyright (c) Zerhex Digital 20013-2018
 * @link       http://www.zerhex.com/
 */


$API_URL = "https://www.streamerportal.com/api/api.php";

//POST VARIABLES
$postfields['key'] = '8784lahho0775a00zhj9z704a0a5'; //API KEY
$postfields['hash'] = 'dssa65sta288878221est';       //API secret hash
$postfields['Request'] = 'POST_DEVICE_CMD';
$postfields['device_serial_id'] = '0B0B0B0B0B0B';
$postfields['cmd'] = 'START';  // (STOP,START,PLAY,PLAY_STOP)


// Call the API
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
$response = curl_exec($ch);
if (curl_error($ch)) {
    die('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch));
}
curl_close($ch);

// Decode response
$jsonData = json_decode($response,true);

//print return data of page.
echo '<pre>';
print_r($jsonData);
echo '</pre>';


?>

Sample Response

<?php 

Array
(
    [success] => 1
    [ret_code] => SUCCESS
    [msg] => DEVICE ONLINE. HERE IS STATUS DATA
    [response] => Array
        (
            [online] => 1
            [msg] => COMMAND [START] SUCCESSUFULLY PROCESSED 
            [device_msg] => SUCCESS
            [cmd] => START
        )

)

?>