add_user.php
/*******************************************
Author: EZhometech
Initial Date: 02/11/2010
Modified Date: 11/15/2022
http://www.ezhometech.com
sales@ezhometech.com
Copyright: EZhometech Inc.
********************************************/
filename: add_user.php
description:
use root token to add 2 users.
<?php
$szezserverip="192.168.0.10";
$szAPIport="17000";
$szuserid="root";
$szpassword="1234";
//
New User Profile
$szUsername1="test";
$szPassoword1="1234";
$szGroupName="basic"; $szExpiredTime="12/30/2019";
$szMaxConnection="1";
$szUsername2="test1";
$szPassoword2="12345";
$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: add 1st user with token
$apiurl=vsprintf("http://%s:%s/server/add_user?token=%s&username=%s&password=%s&group=%s&max_connection=%s&expired_time=%s",array($szezserverip,$szAPIport,$sztoken,
$szUsername1,$szPassoword1,$szGroupName,$szMaxConnection,$szExpiredTime));
$szuptime = file_get_contents($apiurl);
echo $szuptime;
// Web API: add 2nd user with token
$apiurl=vsprintf("http://%s:%s/server/add_user?token=%s&username=%s&password=%s&group=%s&max_connection=%s&expired_time=%s",array($szezserverip,$szAPIport,$sztoken,
$szUsername2,$szPassoword2,$szGroupName,$szMaxConnection,$szExpiredTime));
$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);
?>
|