Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    4

    Default Creating a Wild Card Subdomain with the API

    Hello,

    I am using the CPanel API. I can create a subdomain fine. When I attempt to use the Wild Card character * for the subdomain name, it tells me that my subdomain is empty ''.

    >> [result] => Error from domain wrapper: The subdomain '' is not valid.

    how do I tell the API to use the * just like I would if I was logged into the CPanel?

    Thanks

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    4

    Default Re: Creating a Wild Card Subdomain with the API

    UPDATE


    If I try to name the subdomain

    *.test

    it gets set as

    test

    OR, if I try

    88*.test

    it gets set as

    88.test

    This leads me to believe that the * is being stripped before it can be acted on. I do have Conical set to 1.

  3. #3
    cPanel Development cpanelkenneth's Avatar
    Join Date
    Apr 2006
    Posts
    3,788
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Creating a Wild Card Subdomain with the API

    Since this is a development related topic, I moved the thread to the Developer Discussion forum.

    When you say you are using the cPanel API, which API do you mean? API1, API2, xml-api? Also how are you communicating with the API?

    Could you provide a code snippet that demonstrates how you are performing your task?

    Finally which version of cPanel & WHM are you testing against?
    Kenneth
    Product Manager
    cPanel, Inc.

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    4

    Default Re: Creating a Wild Card Subdomain with the API

    I tried both API1 and API2. I am using PHP. I am obviously making the correct call, connecting, and providing the correct credentials, because if I use a word instead of the wild card, it correctly creates the subdomain.

    Here is the code, I replaced my domain with a place holder, otherwise it is exact. I only tried API1 or API2 at a single time, not both at the same time.


    Code:
    include("api/xmlapi.php");
    
    $domain = "*";
    $rootdomain = 'domain-name-here.COM'; 
    $usecanonicalname = 1; // 1 to use wildcard
    $disallowdot = 0; 
    $dir = 'public_html/';
    
    $arraySubDomain = array( $domain, $rootdomain, $usecanonicalname, $disallowdot, $dir ) ;
    $arraySubDomain2 = array( $dir,$disallowdot, $domain, $rootdomain   ) ;
    
    $subDomain = $xmlapi->api1_query($cpuser, "SubDomain", "addsubdomain", $arraySubDomain); 
    
    $subDomain2 = $xmlapi->api2_query($cpuser, "SubDomain", "addsubdomain", $arraySubDomain2);
    cPanel Version 11.28.86
    WHM 11.28.86

  5. #5
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default Re: Creating a Wild Card Subdomain with the API

    Hi warren77,

    First thing I notice is in your API2 call, the argument array "$arraySubDomain2" is not an associate array. API2 uses key/value name pairings as opposed to API1 which takes it's parameters as ordered arguments. In practical terms, that means when you use the XML-API PHP client class you should pass an associate array to api2_query() and an ordinal array to api1_query().

    If an API2 query with an ordinal argument array works, it's purely coincidental. Per chance, I've seen it work for other calls too, but to be certain, I'll make that an associate array:
    PHP Code:
    $arraySubDomain2 = array( 
                        
    'dir'          => $dir,
                        
    'disallowdot'  => $disallowdot,
                        
    'domain'       => $domain,
                        
    'rootdomain'   => $rootdomain
                        
    ); 
    please verify that this does or does not make a difference in the result of your wildcard domain request.

    Best Regards,
    -DavidN
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  6. #6
    Registered User
    Join Date
    Mar 2011
    Posts
    4

    Default Re: Creating a Wild Card Subdomain with the API

    Thank you, that did the trick.

  7. #7
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default Re: Creating a Wild Card Subdomain with the API

    Great!

    Glad I could help,
    -DavidN
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

Similar Threads & Tags
Similar threads

  1. Creating a Wild Card Subdomain with the API
    By warren77 in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 03-16-2011, 12:24 PM
  2. Wild card DNS for subdomain
    By swapnil_mankar1 in forum New User Questions
    Replies: 2
    Last Post: 05-18-2006, 02:44 PM
  3. Questions About Wild Card + subDomain and Park Domain ?
    By cLub2Share in forum cPanel and WHM Discussions
    Replies: 12
    Last Post: 03-26-2006, 11:23 PM
  4. I have Edit DNS with a wild card but can't creat subdomain ?
    By cLub2Share in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 01-06-2006, 11:44 PM
  5. Wild Card Subdomain!
    By klowner in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 11-13-2005, 10:34 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube