nainil
asked on
cPanel / WHM Api example
Can someone please help me with a working example to use the CPanel / WHM Api.
I would like to update the A record for a particular domain hosted in cPanel / WHM through API.
I would like to update the A record for a particular domain hosted in cPanel / WHM through API.
ASKER
Thank you julianmatz. Sorry for the incomplete information.
I want to implement the same using PHP/MySQL.
The Class you suggested does all except the DNS. I will try to look at the same and try to get the DNS manipulation function. But, if someone can get me a working example for DNS manipulation.
Thanks.
I want to implement the same using PHP/MySQL.
The Class you suggested does all except the DNS. I will try to look at the same and try to get the DNS manipulation function. But, if someone can get me a working example for DNS manipulation.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is an incredible find. Thank you.
I am using the original file and examples. however, on Windows 7, (using WAMP), I get the following error:
Warning: file_get_contents(https://localcpanel.com/xml-api/listaccts) [function.file-get-content s]: failed to open stream: Invalid argument in C:\wamp\www\xmlapi.php on line 731
Any idea how to fix the same?
I am using the original file and examples. however, on Windows 7, (using WAMP), I get the following error:
Warning: file_get_contents(https://localcpanel.com/xml-api/listaccts) [function.file-get-content
Any idea how to fix the same?
ASKER
Also, the code works fine on Linux. So this is a Windows only issue apparently.
I'm not a Windows expert, but I think the error may have something to do with the SSL encryption (https). See if you can get these two DLLs from the PHP5 distribution:
libeay32.dll
ssleay32.dll
libeay32.dll
ssleay32.dll
ASKER
Just found that I did not have Curl setup. It worked fine once I worked on that piece. Thank you.
Glad I was able to help. Good luck with your API!
Using the cPanel XML API can be as easy as making a call to:
https://example.com:2087/xml-api/editzonerecord?domain=example.com&Line=2&ttl=86400
This will return a result in XML format, eg:
<cpanelresult>
<data>
<result>0</result>
<reason>Access denied</reason>
</data>
</cpanelresult>
This result, for example would tell you that the command failed (result=0) because access was denied (reason="Access denied").
To make the API call, you can use any number of programming languages like PHP, Perl, ASP. My choice would be PHP, and I would use curl to make.
http://php.net/manual/en/book.curl.php
Another option would be to simply download an existing cPanel API PHP class and either use it as is or modify it to suit your exact needs. Here's an example:
http://www.phpclasses.org/package/3534-PHP-List-and-manage-details-of-cPanel-hosting-accounts.html
But what scripting language did you have in mind for this?