Does anyone have any PHP code to use with the the new XMLAPI? Any help would be much appreciated.
Regards Dan
www.hostingme.co.uk
Does anyone have any PHP code to use with the the new XMLAPI? Any help would be much appreciated.
Regards Dan
www.hostingme.co.uk
I'm second here.
Please tell us how to use XMLAPI within php script.
Thank you!
Regards, Alexey
Here is an example of how you could use the API with PHP:
<?php
$host = "localhost";
$user = "root";
$accesshash = "[ACCESSHASH]";
header( "Content-type: application/xml" );
$request = "/xml-api/accountsummary?user=${user}";
$cleanaccesshash = preg_replace("'(\r|\n)'","",$accesshash);
// Change 'root' to reseller username as required
$authstr = "root:" . $cleanaccesshash;
$cpanelaccterr = "";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_URL, "https://${host}:2087" . $request);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$curlheaders[0] = "Authorization: WHM $authstr";
curl_setopt($ch,CURLOPT_HTTPHEADER,$curlheaders);
$data=curl_exec ($ch);
curl_close ($ch);
echo $data;
?>
There is also a PHP class that uses the API. It was developed by Arash Hemmat and can be downloaded here:
http://www.phpclasses.org/browse/package/4150.html