Hi there,
This was working a while ago but I think a Cpanel Update has stopped it from working since that is the only thing that has changed since. Could anyone just check through the following code to make sure that there isnt anything obvious I have checked the docs a few times over but cant seem to see anything there.
If I echo the result of the curl it seems to just take me to the cpanel page.PHP Code:function addDomainToCpanel($url,$cpanelusername,$cpanelpassword)
{
$pass = "******";
$queryold = "$url:2083/xml-api/cpanel?user=$cpanelusername&xmlin=<cpanelaction><module>AddonDomain</module><func>addaddondomain</func><args><dir>public_html/domains/domains/$url</dir><newdomain>$url</newdomain><subdomain>$url</subdomain><pass>$pass</pass></args></cpanelaction>
";
$query = "$url:2083/json-api/cpanel?user=$cpanelusername &cpanel_xmlapi_module=AddonDomain&cpanel_xmlapi_func=addaddondomain &cpanel_xmlapi_version=2&dir=public_html/domain/domains/$url&newdomain=$url&subdomain=$url&pass=$pass";
$curl = curl_init();
# Create Curl Object
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
# Allow self-signed certs
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
# Allow certs that do not match the hostname
curl_setopt($curl, CURLOPT_HEADER,0);
# Do not include header in output
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
# Return contents of transfer on curl_exec
$header[0] = "Authorization: Basic " . base64_encode($cpanelusername.":".$cpanelpassword) . "\n\r";
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
# set the username and password
curl_setopt($curl, CURLOPT_URL, $query);
# execute the query
$result = curl_exec($curl);
if ($result == false) {
error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");
echo curl_error($curl);
echo $query;
return 0;
# log error if curl exec fails
}
else
{
echo curl_error($curl);
echo"<br><br>";
echo $query;
echo"<br><br>";
return 1;
}
curl_close($curl);
Thanks
Regards
Chris



LinkBack URL
About LinkBacks
Reply With Quote




