【问题标题】:How to use the WHMCS API without actually displaying WHMCS?如何在不实际显示 WHMCS 的情况下使用 WHMCS API?
【发布时间】:2016-09-29 00:23:13
【问题描述】:

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

【问题讨论】:

    标签: php mysql whmcs


    【解决方案1】:

    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"] = "demo@whmcs.com";
    $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
    

    然后您可以将文件复制到客户端的目录。希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 2019-09-26
      • 1970-01-01
      • 1970-01-01
      • 2015-01-07
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多