This is a small PHP-CURL script, initiates a JSON request to Wowza API to get the realtime status of a STREAM file.
Note that the request is protected by Wowza 'AUTHENTICATION - DIGEST' Mechanism.
**********************************************************************
$wowzaip = '192.168.166.68'; //replace with your wowza ip address
$application = 'live'; //replace with your application name
$streamfile = '10-20160527134707366114.stream'; //replace with your streamfile
//initiate a curl session
$ch = curl_init();
//set http header to json
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Accept: application/json'));
//set wowza request url
curl_setopt($ch, CURLOPT_URL, 'http://'.$wowzaip.':8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/'.$application.'/instances/_definst_/incomingstreams/'.$streamfile.'/monitoring/current');
//set RETURNTRANSFER true. Now return as string instead of output
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//authentication in wowza server
curl_setopt($ch, CURLOPT_USERPWD, "your_username:your_password");
//set HTTPAUTH to CURLAUTH_ANY, required for authentication
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
//execute request
$output = curl_exec($ch);
//close curl session
curl_close($ch);
//echo the json output
echo $output;
**********************************************************************
Comments
Post a Comment