API

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

Request Parameter

The GET_DEVICE_STATUS parameter is used to get real time status information of device.

Request = GET_DEVICE_STATUS

Parameters

Description

device_serial_id

Serial number of the device .


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'] = 'GET_DEVICE_STATUS';
$postfields['device_serial_id'] = '0B0B0B0B0B0B';


// 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.
    [response] => Array
        (
            [online] => 1
            [ip] => 192.168.1.108
            [sn] => SEC72AJKDAF0
            [ver] => 1.4.5
            [last_command] => STATUS_STREAMING
            [server_profile] => Main Studio
            [uptime] => 174903
            [recording] => 0
            [file_system] => 1
            [sdcard_in] => 1
            [screen] => Array
                (
                    [line1] => TX: IDLE.       
                    [line2] => RX: IDLE.       
                )

            [playtitle] => Motivational
            [playlink] => http://s30.streamerportal.com:8533/stream
            [play_servertype] => ICECAST
            [playchan] => 2628
            [selected] => Array
                (
                    [profileid] => 95
                    [title] => Main Studio
                )

        )

)

?>