Creating DNS record using the remote api

Discussion in 'General' started by HellMind, Jun 12, 2011.

  1. HellMind

    HellMind New Member

    Code:
    <?php
    $client_id = '2'; //your client id, lo ignora
    $client_group_id = '3';
    $domain_name = $_REQUEST['domain'];
    $server =1;
    $mbox='info.x.com.';
    $ns='ns1.x.com';
    $ip='20x.21x.2x.1x';
    
    #-------------------
    $username = 'x';
    $password = 'x';
    
    $soap_location = 'http://localhost:8080/remote/index.php';
    $soap_uri = 'http://localhost:8080/remote/';
    
    $client = new SoapClient(null, array('location' => $soap_location, 'uri'      => $soap_uri));
    
    $session_id = $client->login($username,$password);
    //Registry Add
    try {
            $params = array(
                    'server_id' => $server,
                    'origin' => $domain_name, //replace
                    'ns' => $ns,
                    'mbox' => $mbox,
                    'refresh' => 28800,
                    'retry' => 7200,
                    'expire' => 604800,
                    'minimum' => 86400,
                    'ttl' => 86400,
                    'xfer' => "",
                    'also_notify' => "",
                    'update_acl' => "",
                    'active' => 'y',
    
            );
            $client->dns_zone_add($session_id, $client_id, $params);
    }
    catch (SoapFault $e) {
            die('Error: '.$e->getMessage());
    }
    //as add
    try{
            $params = array(
                    'server_id' => $server,
                    'name' => '*',
                    'data' => $ip,
                    'ttl' => 86400,
                    'active' => 'y',
    
            );
            $client->dns_a_add($session_id, $client_id, $params);
    }
    catch (SoapFault $e) {
            die('Error: '.$e->getMessage());
    }
    echo "Agregado";
    ?>
    
    With this code I can add a new soa registry but the client owner is null, it works with every client but not the one I want , which is '2'.(No error apears it just looks like if I were using Id = 0)

    The second problem is to add the 'a' record I need to know the id of the soa registry, how can I get that?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Maybe you mix up sys_userid and client_id here. The client that you use has to exist, so please check that there is really a client with ID 2 in the "client" database table.

    You get the ID back when you add the zone:

    $client->dns_zone_add(....)
     
  3. HellMind

    HellMind New Member

    I found it in the db, also I choosed it using the drop down list box in the web interface where it shows the correct client id.

    Code:
    (2, 1, 1, 'riud', 'riud', '', 'xxxx. Com', 'xxx . Com', '', '', 'xxx 253', 'xx0', 'xxxxo', 'xxxe', 'AR', 'xxxxxxxxxxx7', '', '', '', 'http://xxxxxxx.com', '', '', 1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, 0, 0, 0, 1, NULL, -1, -1, 'no,fast-cgi,cgi,mod,suphp', -1, -1, -1, 0, 'no,jailkit', 0, 1, -1, -1, -1, 1, -1, 0, 'url', 5, -1, 0, 0, 'xxxxxer', '291ad281e640429285d30ff25b66813d', 'es', 'default', 0, '', NULL), 
    
    Maybe it does some validation that i cant pass.

    I will try it, thank you
     
  4. HellMind

    HellMind New Member

    I'm having another issue,
    After I add the dns records I must visit the ispc panel at the registry domain , its like the changes are not active till I do that.

    Maybe I should call another function to refresh de mydns config?
     
  5. HellMind

    HellMind New Member

    I need a function to activate the new dns zone I 've added.
    Where can I search for that?
     
  6. falko

    falko Super Moderator ISPConfig Developer

Share This Page