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!

Cpanel::PublicAPI DomainLookup module

Discussion in 'cPanel Developers' started by morissette, Oct 27, 2011.

  1. morissette

    morissette Well-Known Member

    Joined:
    May 24, 2009
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    66
    Location:
    Austin, TX
    cPanel Access Level:
    Root Administrator
    Can you perform cpanel_api2_request calls using root?

    subroutine:
    Code:
    sub docroot{
            $docroot = $cp->cpanel_api2_request('whostmgr', { 'module' => 'DomainLookup', 'func' => 'getdocroot' },
                    {
                            'domain' => "$domain",
                    }
            );
    }
    
    Strace error:
    alarm(0) = 230
    write(2, "There was an issue with parsing "..., 76There was an issue with parsing the following response from cPanel or WHM:

    ) = 76
    write(2, "There was an issue with parsing "..., 75There was an issue with parsing the following response from cPanel or WHM:
    ) = 75
    exit_group(255)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. morissette

    morissette Well-Known Member

    Joined:
    May 24, 2009
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    66
    Location:
    Austin, TX
    cPanel Access Level:
    Root Administrator
    root@dev [/home/matt/cpapi]# ./cpanel.pl
    Domain? removeme.com
    Server Error from 127.0.0.1: {"data":{"reason":"User parameter is invalid or was not supplied","result":"0"},"type":"text"}

    There was an issue with parsing the following response from cPanel or WHM:

    There was an issue with parsing the following response from cPanel or WHM:

    I'm assuming it's not picking up my user param from the initial:
    my $cp = Cpanel::PublicAPI->new( 'user' => 'root', 'accesshash' => my $accesshash );

    Thoughts?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. sirdopes

    sirdopes Well-Known Member
    PartnerNOC

    Joined:
    Sep 25, 2007
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    66
    You need to pass the user for the domain you are doing a lookup for as well.

    $cp->cpanel_api2_request('whostmgr',
    {
    'module' => 'DomainLookup',
    'func' => 'getdocroot',
    'user' => 'someuser',
    },
    {
    'domain' => "$domain",
    }
    );
     
  4. morissette

    morissette Well-Known Member

    Joined:
    May 24, 2009
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    66
    Location:
    Austin, TX
    cPanel Access Level:
    Root Administrator
    Thanks for the help, might want to update KB: ApiDomainLookup < ApiDocs/Api2 < TWiki

    Code:
    root@dev [/home/matt/cpapi]# ./cpanel.pl 
    Domain? removeme.com
    $VAR1 = {
              'cpanelresult' => {
                                  'apiversion' => 2,
                                  'func' => 'getdocroot',
                                  'data' => [
                                              {
                                                'reldocroot' => 'public_html/removeme.com',
                                                'docroot' => '/home/matt/public_html/removeme.com'
                                              }
                                            ],
                                  'event' => {
                                               'result' => 1
                                             },
                                  'module' => 'DomainLookup'
                                }
            };
    
     
    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