Results 1 to 4 of 4

Thread: WHM XML API ready to use class

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    1

    Lightbulb WHM XML API ready to use class

    Hi
    I made a class to work with WHM XML API and I see no reason to hide it so I shared it on phpclasses, you can download it from here: (You need PHP 5.x to use it)
    http://www.phpclasses.org/browse/package/4150.html
    It can establish secure HTTP connections to a Web server to manage Cpanel/WHM accounts and authenticates on behalf of a given WHM user.
    Please read the README file before using.
    Some of the XML API functions has not been implemented yet but I will add them on the next version.

    I'm waiting for your comments and questions, if you like this class please rate it on phpclasses.

    Regards

  2. #2
    Member
    Join Date
    Jun 2007
    Posts
    41

    Default

    great news ! Thanks a lot for your work

    I'll try it real soon.
    Can you keep us informed whenever you update it ?

    Thank you

    Dominique

  3. #3
    Member
    Join Date
    Jun 2007
    Posts
    22

    Default

    I am going to try it too, thank you for sharing !

  4. #4
    Member
    Join Date
    Nov 2003
    Location
    Panama City, FL
    Posts
    147

    Default

    I'm in the process of playing with your script, and I thought I'd share what I've come up with -- it's not refined yet, but I got it working, and I couldn't find this information laid out anywhere specifically...

    I wanted to add some of the cPanel API2 stuff. The first thing I thought I'd test was to add a forwarder.

    The first thing I did was add a nastly little hacked function to your class:

    PHP Code:
        # Function to pass xml to cpanel
            
    function cpxml($user$xml)
        {
        
            
    $cp_xml '/xml-api/cpanel?user=' $user '&xmlin=' $xml;
        
            
    //connect using prpoer xml api address
            
    $this->connect($cp_xml);
            
    //get the output
            
    $result $this->getOutput();
            
            return 
    $result;
        } 
    I used the example init and result/error display code, and hacked in this function call:

    PHP Code:
    $cp_user 'someuser';
    $cp_xml_start '<cpanelaction>';
    $cp_xml_module '<module>Email</module>';
    $cp_xml_function '<func>addforward</func>';
    $cp_xml_version '<apiversion>2</apiversion>';
    $cp_xml_args '<args><fwdemail>some@email.tld</fwdemail><fwdopt>fwd</fwdopt><domain>some.tld</domain><email>someone</email></args>';
    $cp_xml_end '</cpanelaction>';
    $cp_xml $cp_xml_start $cp_xml_module $cp_xml_function $cp_xml_version $cp_xml_args $cp_xml_end;

    $result=$task->cpxml($cp_user,$cp_xml); 
    It's also ugly, but I was having a heck of a time figuring out how to get it working.

    Part of that was because in the original function, I didn't have "?user=", I just had "?", so I wasn't passing it a cpanel user to work with. D'oh!

    But still, I just couldn't find this laid out and written clearly anywhere.... so I hope you don't mind it in this thread - I hope this saves someone some time.

    Some resources I used:
    http://www.cpanel.net/plugins/xmlapi/
    http://www.cpanel.net/plugins/api2/
    http://www.phpclasses.org/browse/package/4150.html

Similar Threads

  1. XML API PHP Class version 1.0
    By MattDees in forum cPanel Developers
    Replies: 107
    Last Post: 02-24-2011, 08:38 AM
  2. XML API class works with a WHM cPanel reseller account?
    By bcosmo in forum cPanel Developers
    Replies: 1
    Last Post: 03-17-2010, 09:33 AM
  3. Install wildcard ssl using XML API class
    By tomdchi in forum cPanel Developers
    Replies: 4
    Last Post: 02-21-2010, 07:58 PM
  4. WHM XML-API using C# - Help
    By serverportugal in forum cPanel Developers
    Replies: 1
    Last Post: 01-18-2009, 06:28 AM