get_system_uptime.php
/*******************************************
Author: EZhometech
Initial Date: 09/30/2016
Modified Date: 09/30/2016
http://www.ezhometech.com
sales@ezhometech.com
Copyright: EZhometech Inc.
********************************************/
filename: get_system_uptime.php
description:
use token to get server uptime.
<?php
$szezserverip="192.168.0.10";
$szAPIport="17000";
$szuserid="root";
$szpassword="1234";
$str=vsprintf("%s:%s",array($szuserid,$szpassword));
$strenc=base64_encode($str);
// Web API: createtokenbased64
$apiurl=vsprintf("http://%s:%s/token/createtokenbased64?encrpty=%s",array($szezserverip,$szAPIport,$strenc));
$szreponse = file_get_contents($apiurl);
// Get token
$sztoken=substr($szreponse,6,strlen($szreponse)-8);
// Web API: get_system_uptime with token
$apiurl=vsprintf("http://%s:%s/server/get_system_uptime?token=%s",array($szezserverip,$szAPIport,$sztoken));
$szuptime = file_get_contents($apiurl);
echo $szuptime;
// Web API: destroytoken with token
$apiurl=vsprintf("http://%s:%s/token/destroytoken?token=%s",array($szezserverip,$szAPIport,$sztoken));
$szuptime = file_get_contents($apiurl);
?>
|