My example for api add_user use CURL Function

uhopenet

New member
Joined
May 15, 2008
Messages
1
code:
<?php


$arrData = array();
$arrData["action"]='create';
$arrData["add"]='Submit';
$arrData["username"]='os11111120';
$arrData["email"]='[email protected]';
$arrData["passwd"]='AaSs9_';
$arrData["passwd2"]='AaSs9_';
$arrData["domain"]='os120.host1.test.cn';
$arrData["bandwidth"]='1024';
$arrData["quota"]='250';
$arrData["vdomains"]='2';
$arrData["nsubdomains"]='0';
$arrData["nemails"]='0';
$arrData["nemailf"]='0';
$arrData["nemailml"]='0';
$arrData["nemailr"]='0';
$arrData["mysql"]='2';
$arrData["domainptr"]='5';
$arrData["ftp"]='2';
$arrData["cgi"]='ON';
$arrData["php"]='ON';
$arrData["notify"]='no';
$arrData["ip"]='127.0.0.1';

echo(SendCommand($arrData));

function SendCommand($arrData)
{
$url = "http://127.0.0.1:2222/CMD_API_ACCOUNT_USER";
$remote_uname = 'admin';
$remote_passwd = 'password';
$headers = array(
"Accept: */*" ,
"Connection: Close",
"Authorization: Basic ".base64_encode("$remote_uname:$remote_passwd"),
"Content-Type: application/x-www-form-urlencoded",
);

$pairs = array();

foreach ( $arrData as $key => $value )
{
$pairs[] = "$key=".urlencode($value);
}

$content = join('&',$pairs);

unset($pairs);

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, &$headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, FALSE);

$retxml = curl_exec($ch);

if (curl_errno($ch)) {
$retxml="<status>error</status><errcode>".curl_errno($ch)."</errcode><errtext>CURL ERROR:".curl_error($ch)."</errtext>";
}

curl_close($ch);

return $retxml;
}


?>
 
what can i do if i want to make a form and link to this api so that the account will auto cerate after i have typed the information
 
Back
Top