API

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

Request Parameter

The ADD_SERVER_PROFILE parameter is used to add server configuration for broadcasting.

Request = ADD_SERVER_PROFILE

Parameters

Description

username

Email address of the user registered.

servertype

Servertype can be (IECAST,SHOUTCASTV1,SHOUTCASTV2)

title

Any title can be used to identify this profile.

address

Server hostname or ip address to broadcast to.

password

Password of server to broadcast to

port

Port of server to broadcast to

bitrate

Bitrate of audio quality.

samplerate

Audio sample rate. Default = 44100

mountpoint

Server mount point if required.


Example usage :

<?php 


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


$postfields['key'] = '8784lahho0775a00zhj9z704a0a5'; //API KEY
$postfields['hash'] = 'dssa65sta288878221est';       //API secret hash
$postfields['Request'] = 'ADD_SERVER_PROFILE';
$postfields['username'] = 'demo@example.com';
$postfields['servertype'] = 'ICECAST';
$postfields['title'] = 'Main Studio';
$postfields['address'] = 'example.com';
$postfields['port'] = '8000';
$postfields['password'] = 'password';
$postfields['bitrate'] = '128';
$postfields['samplerate'] = '44100';
$postfields['mountpoint'] = '/live';



// 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
(
    [ret_code] => SUCCESS
    [msg] => Profile successfully added
    [response] => Array
        (
            [success] => 1
            [msg] => Profile successfully added
            [profiles] => Array
                (
                    [0] => Array
                        (
                            [id] => 95
                            [userid] => 493
                            [deviceid] => 0
                            [title] => Main Studio
                            [username] => demo@example.com
                            [server] => example.com
                            [serverip] => 93.184.216.34
                            [servertype] => ICECAST
                            [port] => 8000
                            [mountpoint] => /live
                            [pass] => password
                            [url] => 
                            [genre] => 
                            [bitrate] => 128
                            [sample] => 44100
                            [channel] => 0
                            [contenttype] => AUDIO/MPEG
                            [description] => 
                        )

                )

        )
)


?>