dongtong1226 2015-02-26 12:40
浏览 59
已采纳

如何在不实际显示WHMCS的情况下使用WHMCS API?

Is there any way in which i can use the WHMCS API without displaying WHMCS to the clients and users. I want my PHP scripts to first create a WHMCS client, add an order for the client and then copy some files to the client's directory. But i don't want my clients to be able to login to their WHMCS panel or even be able to see the WHMCS

  • 写回答

1条回答 默认 最新

  • doumao6212 2015-02-26 14:23
    关注

    WHMCS has something called External API that will help you.

    Here is the documentation. But for what you need yo should do this:

    Connect to the 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
    

    Add the Client

    $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
    

    Add the Order

    $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
    

    Then you can copy the files to the client's directory. Hope it helps!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀