【问题标题】:How to create an addon domain using xmlapi-php?如何使用 xmlapi-php 创建插件域?
【发布时间】:2013-11-06 18:34:57
【问题描述】:

我正在尝试使用 xmlapi-php 创建一个插件域。我有一个共享主机帐户。

此示例代码来自github

<?php

    include '../xmlapi.php';    
    $ip = getenv('REMOTE_HOST');
    $root_pass = getenv('REMOTE_PASSWORD');

    $domain = "somedns.com";

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);
    $xmlapi->set_http_client('curl');
    $xmlapi->set_port(2086);
    $xmlapi->set_debug(1);

    print $xmlapi->adddns($domain,$ip);            
?>

我无法让此代码用于创建插件域。怎么办?

【问题讨论】:

    标签: php xml api cpanel


    【解决方案1】:

    好吧,我已经尽我所能解决了,这里是所有迷失灵魂的解决方案:

    身份验证

    您需要至少运行一次以下代码以进行身份​​验证和 xml api 包装器:

    // AUTHENTICATION -------------------------
    
      include("xmlapi.php");    
    
      $host = "Host ip address or Site.com";
      $my_user = "Your cPanel user ID";
      $my_pass = "Your cPanel password";
    
      $xmlapi = new xmlapi($host);
      $xmlapi->set_port(2083);
      $xmlapi->password_auth($my_user, $my_pass);
      $xmlapi->set_output('json');
      $xmlapi->set_debug(1);
    

    现在您可以开始使用 xmlapi.php 中提供的功能,但您不仅限于这些功能。

    电子邮件创建示例

    // Calling on the function "addpop" "email_user@email_domain" ------------------------- 
    
      $email_user = "apitest";
      $email_password = "adfm90f";
      $email_domain = "somesite.com";
      $email_query = '10';
      $email_quota = '600';
    
      //$result will be set equal to the JSON output returned by the call
      //api1_query is the function
      //in the array is where you pass the required parameters
    
      $result = $xmlapi->api1_query($my_user, "Email", "addpop", 
      array($email_user, $email_password, $email_quota, $email_domain));
    

    显示结果

     $result = json_decode($result, true); //Decoding the JSON results to PHP
     print_r($result); //Printing the array onto the page
    
     //example of displaying a particular array key, in this example its "result"
    
     echo $result['data']['result'];
    

    【讨论】:

    • 您好,您给出的示例是创建电子邮件。如何在主机中创建额外的域?
    猜你喜欢
    • 1970-01-01
    • 2017-03-17
    • 2011-10-08
    • 2013-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-17
    • 1970-01-01
    相关资源
    最近更新 更多