如何使用cpanel api在我的服务器上托管客户域

时间:2017-03-01 14:05:42

标签: web-hosting cpanel-xmlapi

我在这里搜索很多

https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+2

https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+1

但没有找到任何正确的方法。我的要求是我需要以编程方式在我的服务器上托管域名,我的客户通过表单向我提供其域名(例如:test.com),当他提交该表格时,我将使用该表格设置一个wordpress网站域。目前我使用cpanel api以编程方式设置子域名,我的要求是在我的服务器上托管域名,我必须使用api执行此操作。

2 个答案:

答案 0 :(得分:0)

要与cpanel连接,您将需要cpanel主域,cpanel用户名和cpanel密码。您将与cpanel连接,然后可以轻松创建新的插件域。一旦您创建了addon域,您就可以使用单独的插件域来专门管理每个域。

    require_once '../components/xmlapi.php';

    $xmlapi = new \xmlapi($licence['cpanel_domain']);
    //checking authentication of the cpanel
    $xmlapi->password_auth($licence['username'],$licence['password']);

    $xmlapi->set_port(Yii::$app->params['domainPort']);

    $result = $xmlapi->api1_query($licence['password'], 'CustInfo', 'getemail', array());   

    // Add the "addondomain.com" addon domain.

    $api2args = array(
         'dir'            => 'addondomain/home/dir', 
         'newdomain'      => 'addondomain.com', 
         'subdomain'      => 'subdomain',
    );

    $add_addon = $xmlapi->api2('AddonDomain', 'addaddondomain', $api2args);

答案 1 :(得分:0)

上面我建议了在cpanel上创建插件域的方法。 以下是在WHM或服务器上生成新cpanel帐户的代码

$xmlapi = new \xmlapi($reseller->url);
//checking authentication of the cpanel
$xmlapi->password_auth($reseller->username, $reseller->password);                                                   
$xmlapi->set_port(2087);
$xmlapi->set_output('json');

$conf = array("username"=>$username,"password"=>$password,"domain"=>$domain,"pkgname"=>$package,"contactemail"=>$contactemail,"cpmod"=>"x3");

$result = json_decode($xmlapi->createacct($conf));
相关问题