• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Add client issue with API (Using PHP)

D

Dr_Zaius

Guest
Hi all, I have a reseller account for Plesk Panel and I am trying to automate client creation, on submitting the XML I get the error code "1014" with the error message "Error while scaning: Can not navigate to the specified node/offset", the code does not return an error (or work obviosuly) if I comment out the line "$client->appendChild($add);".

The code is as follows:
$xmldoc = new DomDocument('1.0', 'UTF-8');

$xmldoc->formatOutput = true;



// <packet>

$packet = $xmldoc->createElement('packet');

$packet->setAttribute('version', '1.4.1.2');

$xmldoc->appendChild($packet);



// <packet/client>

$client = $xmldoc->createElement('client');

$packet->appendChild($client);



// <packet/client/add>

$add = $xmldoc->createElement('add');

$client->appendChild($add);



// <packet/client/add/geninfo>

$geninfo = $xmldoc->createElement('geninfo');

$add->appendChild($geninfo);



// create child element

$cname = $xmldoc->createElement("cname");

$geninfo->appendChild($cname);



// create text node

$text = $xmldoc->createTextNode("test company");

$cname->appendChild($text);



// create child element

$pname = $xmldoc->createElement("pname");

$geninfo->appendChild($pname);



// create text node

$text = $xmldoc->createTextNode("test name");

$pname->appendChild($text);



// create child element

$login = $xmldoc->createElement("login");

$geninfo->appendChild($login);



// create text node

$text = $xmldoc->createTextNode("testlogin");

$login->appendChild($text);



// create child element

$passwd = $xmldoc->createElement("passwd");

$geninfo->appendChild($passwd);



// create text node

$text = $xmldoc->createTextNode("testpass");

$login->appendChild($text);



// create child element

$status = $xmldoc->createElement("status");

$geninfo->appendChild($status);



// create text node

$text = $xmldoc->createTextNode("0");

$login->appendChild($text);



// create child element

$phone = $xmldoc->createElement("phone");

$geninfo->appendChild($phone);



// create text node

$text = $xmldoc->createTextNode("0123456789");

$phone->appendChild($text);




// <packet/client/add/template-name>

$templatename = $xmldoc->createElement('template-name');

$add->appendChild($templatename);



// create text node

$text = $xmldoc->createTextNode("Unlimited Plan");

$templatename->appendChild($text);

Can anyone advise where I am going wrong here?
 
Back
Top