|
|||
|
WHM / cPanel API
Hello,
We are working to a PHP API Class for WHM and cPanel. We are going to include all functions. Structure will be something like: WHM.php => main class Account.php => accounting class Reseller.php => reseller class Dns.php => dns class Ssl.php => ssl class Package.php => package class Serverinfo.php => server information class Serveradmin.php => server administration class ================================================ An example of use: We need to call only WHM.php $config['whm_user'] = 'user_here'; $config['whm_user'] = 'url_here'; $config['whm_hash'] = 'hash_generated_from_whm'; $whm = new WHM('account' , $config); first parameter 'account' is the action. you need to create a dns? just replace is with "dns" creating an account; $prepare = $whm->do->createacct('user','domain','email',$extraoption s) $extraoptions is array (ex ;$extraoptions['plan'] = 'planname'; $extraoptions['reseller'] = '1'; $prepare is the query string; to finish the account creation you will only need to run $result = $whm->exec($prepare); Where the $result is the array of xml response example to view the status echo $result['status']; ================================================== ==== All functions names will be as WHM "createacct,listaccts,modifyacc,addzonerecord, etc" Any ideas are welcome |
|
||||
|
Will this class be based off the XML API and utilize API1 and API2 for cPanel functionality (if you're offering any)? I ask because this is the recommended way of interfacing with our software and is more reliable than screen scraping and operate independently of whatever themes servers are utilizing.
If you need help interfacing with anything, just let us know .
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit |
|
|||
|
I've changed the structure.
There will be a WHM Loader class. So will working something like this. $conn = array (define the WHM connection); $loader = new WHM_Loader(); $loader->setPath('path_to_whmclasses_folder'); // example; $accouting = $loader->load('accouting' , $conn); $accouting->create_acct( .... ) $accouting->modifyacct( .... ) $dns = $loader->load('dns' , $conn); $dns->editzonerecord('domain_name','host' , $options=array()); // improved dns options $dns->editArecord('domain_name','current_host',$options =array()); available options for function editArecord new_ip new_host ttl So will be very easy for people who wanna make a DNS manager interface. $dns->editCNAMERecord( ... ) $dns->editMXRecord( ...) // for cpanel. $email = $loader->loadcp('email' , $conn); $email->addforward( ... ); $email->listmxs( ... ) $ftp = $loader->loadcp('ftp' , $conn); $ftp->listftpsessions( ... ) |
|
|||
|
Update.
How easy is to create an account. $new_account['user'] = 'user_here'; $new_account['pass'] = 'pass_here'; // leave empty class will generate automatic a password $new_account['domain'] = 'domain_name'; $new_account['email'] = 'customer_email_address'; $new_account['plan'] = 'your_hosting_plan'; $new_account['reseller'] = 0 or 1 $response = $accounting->createacct($new_account); $response is an array and looks like: $response['action'] = 'createacct'; $response['set'] is an array with data configured by you, example: $reponse['set']['user'] will return the user configured by you. $response['get'] is the array with data returned by XML-API $response['result] is: 1 - ok 0 - not ok $reponse['resultmsg'] = the error $response['data'] = return a storable representation of all data. // changing the primary domain; $result = $accounting->changePrimaryDomain($user , $newdomain); |
|
|||
|
So i need your opinion about structure:
-> WHM_loader (loading WHM/cPanel functions) -> WHM (main class, handle connection, query builder, etc) classes( ::: API1 ::: -> Accounting (implements WHM, handle account functions -> Dns (implements WHM, handle dns functions) -> Package (implements WHM, handle package functions) -> Reseller Functions (implements WHM, handle reseller functions) -> Server Informations (implements WHM, handle server informations) -> Server administration (implements WHM, handle server administration functions) -> Service functions (implements WHM , handle service functions) -> SSL functions (implements WHM , handle service functions) ::: API2 ::: (same as API1) implements WHM and handle all operations listed on ApiTwo < AllDocumentation/AutomationIntegration < TWiki WHM_Loader will be only need to be included and working as: PHP Code:
if you want to add something to this, please let me know. |
|
|||
|
Array result for account creation.
PHP Code:
To convert the array into XML and add in array $result['xml_data'] = XML ? will look something like <WHM> <createacct> <set> <username>user</username> </set> <get> <ip>1.1.1.1</ip> </get> <action>createacct</action> <date>date</date> <time>time</time> <result>1</result> <resultmsg>restult msg </resultmsg> </createacct> </WHM> Last edited by paulipv; 07-08-2009 at 07:39 AM. |
|
||||
|
Sounds great! Let us know if you need anything.
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit |
|
|||
|
David,
This is the XML/Array result generated by our class for account domain modification. How looks to you? PHP Code:
PHP Code:
|
|
||||
|
Taking a quick glance, it's an interesting alternative implementation
.
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| cPanel/WHM API? | hb-travisbell | cPanel and WHM Discussions | 2 | 11-26-2006 06:42 PM |
| cPanel / WHM API for PHP5 | Spiral | cPanel and WHM Discussions | 4 | 10-18-2006 02:54 PM |
| cPanel/WHM API help | webadpro | cPanel and WHM Discussions | 5 | 03-02-2006 03:18 PM |
| CpanelAppz.com WHM/cpanel API | anand | Developer Discussions | 27 | 02-10-2005 09:13 AM |
| Cpanel/Whm API | farshad_s3 | cPanel and WHM Discussions | 17 | 09-17-2004 01:14 PM |