The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WHM XML API ready to use class

Discussion in 'General Discussion' started by arash_hemmat, Sep 28, 2007.

  1. arash_hemmat

    arash_hemmat Registered

    Joined:
    Sep 28, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    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. dom974

    dom974 Active Member

    Joined:
    Jun 24, 2007
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    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. Webou

    Webou Member

    Joined:
    Jun 6, 2007
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    I am going to try it too, thank you for sharing !
     
  4. Ishware

    Ishware Well-Known Member

    Joined:
    Nov 7, 2003
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Panama City, FL
    cPanel Access Level:
    Root Administrator
    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:
        # 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:
    $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
     
Loading...

Share This Page