CpanelInc -xmlapi-php "No host defined" 错误
CpanelInc -xmlapi-php "No host defined" Error
最近我试图在 this class 的帮助下创建一个数据库及其用户。我尝试了以下代码。
include_once("xmlapi.php"); // this can be downlaoded from https://github.com/CpanelInc/xmlapi-php/blob/master/xmlapi.php
$ip = getenv('REMOTE_HOST');
$root_pass = getenv('REMOTE_PASSWORD');
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth("root",$root_pass);
$xmlapi->set_debug(1);
$acct = array( username => "someuser", password => "pass123", domain => "exampledoamin.com"); // here i used my domain name.
print $xmlapi->createacct($acct);
但它return出现以下错误。
Fatal error: Uncaught exception 'Exception' with message 'No host defined' in
当我需要主文件时它显示错误。我的代码有什么问题。我找不到错误。我是不是漏了什么。
编辑:
Var_dump($ip);
bool(false)
;
最后我通过重写代码解决了这个问题。在这里。
include_once("xmlapi.php");
$ip = "hostname";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth("cpanel_user-name","Password");
$xmlapi->set_port(2083);
$xmlapi->set_debug(1);
print $xmlapi->get_host();
那么,连接上主机了
最近我试图在 this class 的帮助下创建一个数据库及其用户。我尝试了以下代码。
include_once("xmlapi.php"); // this can be downlaoded from https://github.com/CpanelInc/xmlapi-php/blob/master/xmlapi.php
$ip = getenv('REMOTE_HOST');
$root_pass = getenv('REMOTE_PASSWORD');
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth("root",$root_pass);
$xmlapi->set_debug(1);
$acct = array( username => "someuser", password => "pass123", domain => "exampledoamin.com"); // here i used my domain name.
print $xmlapi->createacct($acct);
但它return出现以下错误。
Fatal error: Uncaught exception 'Exception' with message 'No host defined' in
当我需要主文件时它显示错误。我的代码有什么问题。我找不到错误。我是不是漏了什么。
编辑:
Var_dump($ip);
bool(false)
;
最后我通过重写代码解决了这个问题。在这里。
include_once("xmlapi.php");
$ip = "hostname";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth("cpanel_user-name","Password");
$xmlapi->set_port(2083);
$xmlapi->set_debug(1);
print $xmlapi->get_host();
那么,连接上主机了