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.

Help me with using API2 Park?

Discussion in 'cPanel Developers' started by DonB, Apr 18, 2014.

  1. DonB

    DonB Member

    Joined:
    Apr 18, 2014
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    I am getting the following when I try to Park an account with my PHP script:

    [18-Apr-2014 18:20:29 UTC] SimpleXML var_dump:
    SimpleXMLElement Object
    (
    [apiversion] => 2
    [data] => SimpleXMLElement Object
    (
    [reason] => The domain example.com does not exist.
    [result] => 0
    )

    [error] => The domain example.com does not exist.
    [event] => SimpleXMLElement Object
    (
    [result] => 1
    )

    [func] => park
    [module] => Park
    )

    As you can see, the domain name 'doubles-up' and thus 'does not exist'.

    my script:

    Code:
    $xmlapi = new xmlapi($ip);
    $xmlapi->set_user($whmusername);
    $xmlapi->hash_auth($whmusername, $whmhash);
    
    $xmlapi->set_debug(1);
    
    $xmlapi->api2_query($whmusername, 'Park', 'park', array( 'domain' => 'example.com', 'topdomain' => 'example.com' ) ); 
    
    Leaving the domain name blank (expecting the duplication would go away), gives me a message 'You may not have more than 0 parked domains.'

    I have tried two different username, first: the control panel username, second: the account name 'crebuyer' for the topdomain.

    What's odd is I can Unpark, so clearly I have the necessary permissions to manipulate the parking data.

    I saw a few other similar sounding threads here and tried without success to extrapolate from them for a solution.

    WHM info:
    CENTOS 6.5 x86_64 standard
    WHM 11.42.1 (build 5)
     
    #1 DonB, Apr 18, 2014
    Last edited by a moderator: Apr 20, 2014
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Did you verify the package assigned to this account allows for more than 0 parked domains?

    Thank you.
     
  3. DonB

    DonB Member

    Joined:
    Apr 18, 2014
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Would that be somehow different from the fact I can park domains using WHM? The domain I unparked was one I parked using WHM.

    I am supposed to have unlimited ability to park domains and create new accounts in my account, which is a 'reseller' account (not sure if that's a term cpanel uses or just my hosting company. I have a 'reseller' account with them, which grants me WHM access and thus access the mechanism for parking domains. I have a main account I log in with to access Cpanel and WHM, and from there I can create more accounts to use, sell subscriptions to, etc.

    What about the way the error messages report back the 'The domain example.com.example.com does not exist' ? [By the way, it appears something/someone altered my post to change the actual error message and domain names and obliterated the actual info I pasted in.
     
  4. DonB

    DonB Member

    Joined:
    Apr 18, 2014
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    On further review, I see my quoted block on my initial post is ALSO misleading. The 'domain' and 'topdomain' values were NOT both 'example.com' They were different. The 'domain' was intended to park onto 'topdomain'. I guess this forum has some rule against posting actual domain names so I won't bother repeating them. Suffice to say, the topdomain was added through WHM by 'add account' and is operational. The 'domain' is a second name I wanted to park onto that one. I do this routinely through WHM but have the need to automate the process as a large number of domains and parking will be underway.
     
  5. DonB

    DonB Member

    Joined:
    Apr 18, 2014
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    If it helps, the park command is POSTed as follows (although the hash shown is no longer value for security reasons):

    Code:
    Array
    (
        [0] => Authorization: WHM fajdnqjb:c533ebb998e3d3ec15250d5a4e40c91822dc03eed29cec3385ecff892dec5ff8ede2ef2fae448f602cc590bb6e96fc16d101db52ee56696ef32cf4639aced61e58dcbf25cfca1ddeef0601e030acdaa3dbba0d4fd005c3800096589ae5ceecebfeeed14df4f02a02e1135e6a2fe498062e604b5dc168b900e8b8a80299fc0c8dfff884b13e65a89183cabc9242e26de12d53caba2ee06be326fcea55e5109abedab1e4c11a05e1280ec953e968b1e69db065e03354d6a429e9d9985805dea9ae69d6060c8468a4a0faed61d2314ce413a35b98101e4eebbb98b352a1acee0b69ecf508be49529e685b8e82edea5debb16fcca4be5e22de9010bae315624256d0a1461453e5882a10556236eb8e518120646884afeefb099d85ee8f4236bcf3fdb1c960d21f3befcbe0232c8d9850402f000fcc4c63ee6bc423f1185146c2e541c3d58b4b65c2e95fe2ac5ffd4cd9e3a5d4243d09f61ae0413a5494daac239b48c5a2aa68d2d01cefd994e2e0fe58f332f142e211ca33eea401ba2a0adbdfe3d96803b2a6900ee1dd0c0dbcfec39fa6383f58b2daa568fff3fc292e99aac8982dde5c6210dfed9aefd0be06becfd5fce383bffeb62cca1e2e5565ea6fe6d3c6fb63b4625f368fb165e8d4c818e26b4ae9
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 158
    
    domain=PlumbingNewYorkCity.com&topdomain=crebuyer.com&cpanel_xmlapi_user=crebuyer&cpanel_xmlapi_module=Park&cpanel_xmlapi_func=park&cpanel_xmlapi_apiversion=2
    )
    
    That post returned the following to my script (bear in mind to keep from having the domain names mangled again, I changed the '.' to ',' in the quote:

    Code:
    SimpleXMLElement Object
    (
        [apiversion] => 2
        [data] => SimpleXMLElement Object
            (
                [reason] => The domain “crebuyer,com.crebuyer,com” does not exist.
                [result] => 0
            )
    
        [error] => The domain “crebuyer,com.crebuyer,com” does not exist.
        [event] => SimpleXMLElement Object
            (
                [result] => 1
            )
    
        [func] => park
        [module] => Park
    )
    
     
    #5 DonB, Apr 21, 2014
    Last edited by a moderator: Apr 21, 2014
  6. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Seems like this API call is documented incorrectly. The topdomain parameter is actually just the prefix of the subdomain you are parking this new domain to. What's also weird is that subdomain has to exist before you can park ontop of it. So, you'll need to call SubDomain::addsubdomain() like so:

    Code:
    ?cpanel&domain=subdomain&rootdomain=domain.com&cpanel_xmlapi_user=user&cpanel_xmlapi_module=SubDomain&cpanel_xmlapi_func=addsubdomain&cpanel_xmlapi_apiversion=2
    
    to create subdomain.domain.com and then, call Park:: park() with the subdomain prefix like so to park on that subdomain:

    Code:
    ?cpanel&domain=domain.com&topdomain=subdomain&cpanel_xmlapi_user=user&cpanel_xmlapi_module=Park&cpanel_xmlapi_func=park&cpanel_xmlapi_apiversion=2
    
     
  7. DonB

    DonB Member

    Joined:
    Apr 18, 2014
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Well, I did discover the account 'crebuyer' was set to zero parked/addon domains so I made it non zero. I got this error afterwards:

    SimpleXMLElement Object
    (
    [apiversion] => 2
    [data] => SimpleXMLElement Object
    (
    [reason] => Sorry, the domain is already pointed to an IP address that does not appear to use DNS servers associated with this server. Please transfer the domain to this servers nameservers or have your administrator add one of its nameservers to /etc/ips.remotedns and make the proper A entries on that remote nameserver.
    [result] => 0
    )

    [error] => Sorry, the domain is already pointed to an IP address that does not appear to use DNS servers associated with this server. Please transfer the domain to this servers nameservers or have your administrator add one of its nameservers to /etc/ips.remotedns and make the proper A entries on that remote nameserver.
    [event] => SimpleXMLElement Object
    (
    [result] => 1
    )

    [func] => park
    [module] => Park
    )

    Now, this isn't the Master Reseller account, which is where I really intend to do the parking, but it was a place to experiment. I did so because I also was unable to park on the Master Reseller (same problem happens with it).

    The domain name I am trying to park is one of mine, is pointed to the nameservers of my Master Reseller site and in fact allowed me to park domains onto it using the Cpanel Parked Domains applet.

    So I'm obviously clueless about some subtlety in the XmlApi mechanism. is there some tutorial that thoroughly covers the parking process? I've seen a number of cryptic discussions that unfortunately seem (to me) to assume prior knowledge that I am lacking.
     
  8. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    You may want to try parking the domain from the cPanel UI to see if you get a more understandable error message. Other than that, I'd recommend opening up a support ticket if the nameservers in the domain you are trying to park's DNS record point to the name servers that you have configured for new accounts in WHM.

    I believe that if you are trying to park on an account that is owned by root, the nameservers will have to match those which are defined in 'Basic cPanel/WHM Setup', and if you are trying to park on an account that is owned by a reseller, the nameservers will have to match those defined in 'Edit Reseller Nameservers and Privileges'.
     
  9. DonB

    DonB Member

    Joined:
    Apr 18, 2014
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    There was some confusion about which nameservers I need use. The PHP script 'lies' to me when I call dns_get_record($host), giving one pair of names while the reseller account shows another when I nslookup it. I found a third, different set of names in WHM "Basic cPanel & WHM Setup". After trial and error, I found the correct ones to enter into the domain registrations of the domains I need to park, updated there and now I can park them.

    Although in the process of sorting this out, I made a call to adddns($domain) and found that killdns($domain) throws a fatal error (evidently I have insufficient rights for deleting?). But I don't need to adddns() so that doesn't really factor into this, just mentioning it in case someone else stumbles into my ramblings in the future.
     
Loading...

Share This Page