有什么方法可以使用WHMCS API而不向客户端和用户显示WHMCS。
我希望我的PHP脚本首先创建一个WHMCS客户端,为该客户端添加一个订单,然后将一些文件复制到该客户端的目录中。
但是我不希望我的客户能够登录到他们的WHMCS面板,甚至不能看到WHMCS

最佳答案

WHMCS有一个叫做External API的东西可以为您提供帮助。

这是documentation。但是对于您所需要的,您应该这样做:

连接到API

$url = "http://www.yourdomain.com/includes/api.php"; # URL to WHMCS API file goes here
$username = "Admin"; # Admin username goes here
$password = "demoxyz"; # Admin password goes here


添加客户端

$postfields = array();
$postfields["username"] = $username;
$postfields["password"] = md5($password);
$postfields["action"] = "addclient";
$postfields["firstname"] = "Test";
$postfields["lastname"] = "User";
$postfields["companyname"] = "WHMCS";
$postfields["email"] = "[email protected]";
$postfields["address1"] = "123 Demo Street";
$postfields["city"] = "Demo";
$postfields["state"] = "Florida";
$postfields["postcode"] = "AB123";
$postfields["country"] = "US";
$postfields["phonenumber"] = "123456789";
$postfields["password2"] = "demo";
$postfields["customfields"] = base64_encode(serialize(array("1"=>"Google")));
$postfields["currency"] = "1";

$query_string = "";
foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$jsondata = curl_exec($ch);
if (curl_error($ch)) die("Connection Error: ".curl_errno($ch).' - '.curl_error($ch));
curl_close($ch);

$arr = json_decode($jsondata); # Decode JSON String

print_r($arr); # Output XML Response as Array


添加订单

$postfields = array();
$postfields["username"] = $username;
$postfields["password"] = md5($password);
$postfields["action"] = "addorder";
$postfields["clientid"] = "1";
$postfields["pid"] = "1";
$postfields["domain"] = "whmcs.com";
$postfields["billingcycle"] = "monthly";
$postfields["addons"] = "1,3,9";
$postfields["customfields"] = base64_encode(serialize(array("1"=>"Google")));
$postfields["domaintype"] = "register";
$postfields["regperiod"] = "1";
$postfields["paymentmethod"] = "mailin";

$query_string = "";
foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$jsondata = curl_exec($ch);
if (curl_error($ch)) die("Connection Error: ".curl_errno($ch).' - '.curl_error($ch));
curl_close($ch);

$arr = json_decode($jsondata); # Decode JSON String

print_r($arr); # Output XML Response as Array


然后,您可以将文件复制到客户端的目录。希望能帮助到你!

关于php - 如何在不实际显示WHMCS的情况下使用WHMCS API?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28742750/

10-11 01:23