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.

cPanel API - PHP Class vs. Email Responder

Discussion in 'cPanel Developers' started by Jack.Straw, Sep 2, 2010.

  1. Jack.Straw

    Jack.Straw Member

    Joined:
    Nov 30, 2006
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Hello. I am trying to develop a simple page to allow users to create, edit, & remove autoresponders. I'm using the PHP class located here:

    cPanel PHP API | Download cPanel PHP API software for free at SourceForge.net

    I am able to remove responders without a problem. However, attempting to add a responder results in the error message:

    Call to a member function getData() on a non-object. (line 587)

    Inspecting the PHP class i see this:
    Code:
    $response = $this->HTTP->getData('mail/doaddars.html', array(
    'email'   => $email,
    'domain'  => $domain,
    'from'    => $from,
    'subject' => $subject,
    'html'    => (bool)$html,
    'body'    => $body,
    'charset' => $charset));
    
    I see the file "mail/doaddars.html" which i'm guessing is the problem, since i have no such file. I even checked the mail folder in the root directory. Can anyone tell me what i'm doing wrong? Unfortunately the php class has no documentation other than the comments in the class itself, which are not helpful in this case.

    Thanks in advance for any advice you can offer,
    -Scott
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi Scott,

    I've never used Atska's "cpanelphpapi", so I can't really speak to it other than the usage you've posted shows that it doesn't use or APIs but instead just submits data to an html page. That can work alot of the time, and sometimes might be the only way, but it isn't the preferred way to integrate with cPanel.

    We recommend using API1, API2 and the XML-API APIs. For PHP folk, leveraging these APIs is super simple with our XML-API PHP client class
    There are examples in that tarball that should get you pointed in the right direction as far as using it. Plus, there's tons of threads in the forum, include a big sticky thread (the first post, I think, in the Developer Discussion section).

    In particular, you'll probably to want to use the following calls; these links point to their documentation, so you know what arguments you'll need to pass:
    API1: addautoresponder - adds responder
    API1: delautoresponder - removes responder
    API2: fetchautoresponder - gets all the detail for a responser
    API2: listautoresponders - simple list of all responders

    Give me a holler if you need more specifics on the XML-API PHP client class or how to envoke those API calls using it.

    Regards,
    -David
     
  3. Jack.Straw

    Jack.Straw Member

    Joined:
    Nov 30, 2006
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    David, thanks a bunch! I'll give that a shot
     
Loading...

Share This Page