Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

php example uapi?

Discussion in 'cPanel Developers' started by jeffschips, Jun 12, 2016.

Tags:
  1. jeffschips

    jeffschips Active Member

    Joined:
    Jun 5, 2016
    Messages:
    29
    Likes Received:
    3
    Trophy Points:
    3
    Location:
    new york
    cPanel Access Level:
    Root Administrator
    Hello.

    I am new and trying to use the uapi php functionality to create email filters. The examples given in the documentation at this link, do not run when I use my code, below. I wish to execute this from the command line.

    when running the file as: php test.livephp no errors come back but no filters are created either.

    What am I doing wrong?


    Code:
    <?php
    
    include("/usr/local/cpanel/php/cpanel.php");
    
    $cpanel = &new CPANEL();
    
    $new_filter = $cpanel->uapi(
        'Email', 'store_filter',
        array(
            'filtername'      => 'coffee',
            'account'         => 'name@thedomain.com',
            'action1'         => 'deliver',
            'dest1'           => 'anothername@thedomain.com',
            'part1'           => '$header_subject:',
            'match1'          => 'contains',
            'val1'            => 'curds',
            'opt1'            => 'or',
            'part2'           => '$message_body',
            'match2'          => 'is',
            'val2'            => 'whey',
             )
    );
    
    ?>
    
     
    #1 jeffschips, Jun 12, 2016
    Last edited by a moderator: Jun 13, 2016
  2. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,762
    Likes Received:
    116
    Trophy Points:
    343
    cPanel Access Level:
    Root Administrator
    If you are going to be doing this from the command-line, why not just use the /usr/local/cpanel/bin/uapi binary?
     
  3. jeffschips

    jeffschips Active Member

    Joined:
    Jun 5, 2016
    Messages:
    29
    Likes Received:
    3
    Trophy Points:
    3
    Location:
    new york
    cPanel Access Level:
    Root Administrator
    You raise an option which I have tried and the binary on the command line works, but I need to pass variables set by administrator to the binary, so I figured a php script will do that.

    Also, I've tried calling the binary from a bash script and can't get that to work either.

    Any options viable for passing variables I'll consider.

    Thank you!
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Could you let us know the specific command you used? Did you utilize URI-encode values?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice