CpanelInc-xmlapi-php";没有主机定义“;错误


CpanelInc -xmlapi-php "No host defined" Error

最近我试图在这个类的帮助下创建一个数据库及其用户。我尝试了以下代码。

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);

但是它返回以下错误。

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();

比,它与主机相连。