help.dyn.com Open in urlscan Pro
138.1.125.45  Public Scan

Submitted URL: http://help.dyn.com/soap-examples-using-php-api/
Effective URL: https://help.dyn.com/soap-examples-using-php-api/
Submission: On September 06 via manual from BR — Scanned from DE

Form analysis 1 forms found in the DOM

https://help.dyn.com/

<form action="https://help.dyn.com/" class="navbar-form navbar-left" role="search">
  <div class="form-group">
    <input type="text" id="s" name="s" value="" placeholder="Search Dyn Help">
    <input type="submit" value=">>" id="searchsubmit">
  </div>
</form>

Text Content

Toggle navigation
 * Product Knowledge Base
   * Articles by Product
   * Dynamic DNS (DynDNS Pro)
   * Managed DNS
   * Standard DNS
   * Email Delivery
   * Domain Registration
   * Application Support Articles
   * Mobile Apps
   * Update Clients
   * Billing + FAQs
   * Billing & FAQs
   * Glossary
 * How-To Videos
   * Managed DNS
   * Dynamic DNS (DynDNS Pro)
   * Traffic Steering
   * Standard DNS
   * Email Deliverability
   * DynEdu
 * Developers
   * All Developer Resources
   * Managed DNS API Documentation
   * Email Delivery API Documentation
   * Traffic Steering API Documentation
   * Dynamic DNS API Documentation
   * SDK for DNS + Email
   * Python
   * PHP
 * Contact Support
   * User to User Support
   * Dyn User Community
   * Dyn Customer Support
   * Email Customer Support
   * Phone Support (except Dynamic DNS)
   * Managed DNS/Email Delivery Tech Support
   * Managed DNS Support (Login Required)
   * Email Delivery Support (Login Required)
 * Sign In
   * Home User Portals
   * Dynamic DNS (DynDNS Pro)
   * Standard DNS
   * Product Portals (DynID)
   * Managed DNS
   * Email Delivery


 * Home /
 * SOAP Examples Using PHP (API)


SOAP EXAMPLES USING PHP (API)


UNDERSTANDING HOW THE API WORKS

 * Get Any Record                              

 * Manage Zones with Node List                              

PHP EXAMPLES – GET ANY RECORD

Here’s a PHP example using the PHP Soap Client class:

 1. Login and Acquire a Session Token [SessionLogin]
 2. Get a list of All Records [GetANYRecords]
 3. Logout a Session [SessionLogout]

Click to view the example code.

<?php
 # Dynect API SOAP Examples - PHP
 # The Base Dynect API2 URL
 $base_url = 'https://api2.dynect.net/wsdl/3.0.0/Dynect.wsdl ';
 
 # Connect to the WSDL
 $client = new SoapClient($base_url, array('cache_wsdl' => 0));
 ?>
 
 <?php
 
 /* ##########################
 
 Logging In
 ------------
 To log in to the dynect API you must call SessionLogin with customer name, username and password
 
 Some Returned Values
 status - success or failure
 data->token - to be used with all other commands
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'user_name'=> 'user_name',
  'customer_name' => 'customer_name',
  'password' => 'password'
  )
  );
 
 echo '<b>Logging In</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('SessionLogin',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  $token = $result->data->token;
  echo '<pre>'; print_r($result->data); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Log in');
 }
 
 ?>
 
 
 <?php
 /* ##########################
 
 Getting All Records on a zone
 ------------
 To get a list of all records send a GetANYRecords command with the token, zone, and fqdn as paramters
 
 Some Returned Values
 status - success or failure
 data - object containing a list record type containers each with the rdata, fqdn, record_type, ttl and zone
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token, 
  'zone' => 'test.com',
  'fqdn' => 'test.com'
  )
  );
 
 echo '<b>Retrieving all Records</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('GetANYRecords',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result->data); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Get records');
 }
 
 ?>
 
 
 <?php
 
 /* ##########################
 
 Logging Out
 ------------
 To log in to the dynect API you must call SessionLogout with the token received at login
 
 Some Returned Values
 status - success or failure
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token
  )
  );
 
 echo '<b>Logging Out</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('SessionLogout',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Log out');
 }
 
 ?>

PHP EXAMPLES - MANAGE ZONES WITH NODE LIST

Here's a PHP example using the PHP SoapClient class:

 1. Login and Acquire a Session Token [SessionLogin]
 2. Get a List of Zones [GetZones]
 3. Get a Specific Zone Detail [GetOneZone]
 4. Add an A record to a node [CreateARecord]
 5. Publishing a Zone [PublishZone]
 6. Get a node list under a Zone [GetNodeList]
 7. Delete a Zone Node [PruneZone]
 8. Logout a Session [SessionLogout]

Click to view the example code.

<?php
 
 # Dynect API SOAP Examples - PHP
 
 # The Base Dynect API2 URL
 $base_url = 'https://api2.dynect.net/wsdl/3.0.0/Dynect.wsdl ';
 
 # Connect to the WSDL
 $client = new SoapClient($base_url, array('cache_wsdl' => 0));
 
 ?>
 
 <?php
 
 /* ##########################
 
 Logging In
 ------------
 To log in to the dynect API you must call SessionLogin with customer name, username and password
 
 Some Returned Values
 status - success or failure
 data->token - to be used with all other commands
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'customer_name' => 'customer_name',
  'user_name'=> 'user_name',
  'password' => 'password'
  )
  );
 
 echo '<b>Logging In</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('SessionLogin',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  $token = $result->data->token;
  echo '<pre>'; print_r($result->data); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Log in');
 }
 
 ?>
 
 <?php
 
 /* ##########################
 
 Get Zones
 ------------
 To get a list of all zones on an account call GetZones with the token from logging in as a parameter
 
 Some Returned Values
 status - success or failure
 data - Array of objects containing zone,serial_style, serial, and zone_type
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token
  )
  );
 
 echo '<b>Getting your list of Zones</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('GetZones',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result->data); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Get Zones list');
 }
 
 ?>
 
 <?php
 
 /* ##########################
 
  Get a Specific Zone detail
 ------------
 To get a list of all zones on an account call GetOneZone with the token from logging in and the zone as a parameter
 
 Some Returned Values
 status - success or failure
 data - object containing zone,serial_style, serial, and zone_type
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token,
  'zone' => 'test.com'
  )
  );
 
 echo '<b>Fetching Details about your Zone</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('GetOneZone',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result->data); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Get Zone Data');
 }
 
 ?>
 
 <?php
 
 /* ##########################
 
 Add an A record to a node
 ------------
 To add an A record to a zone send a CreateARecord with the token from logging in and following paramters
 
 { 
  'fqdn' => 'www.example.com', 
  'rdata' => { 'address' => '1.2.3.4', }, 
  'ttl' => '3600', 
  'zone' => 'example.com', 
  } 
 
 Some Returned Values
 status - success or failure
 data - object containing record_id, rdata, record_type, fqdn, and zone
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token,
  'fqdn' => 'foo.test.com', 
  'rdata' => array( 'address' => '1.2.3.4' ), 
  'ttl' => '3600', 
  'zone' => 'test.com'
  )
  );
 
 echo '<b>Adding A Record to Zone Node</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('CreateARecord',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result->data); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Create A Record');
 }
 
 ?>
 
 <?php
 
 /* ##########################
 
 Add an A record to a node
 ------------
 To add an A record to a zone send a CreateARecord with the token from logging in and following paramters
 
 { 
  'fqdn' => 'www.example.com', 
  'rdata' => { 'address' => '1.2.3.4', }, 
  'ttl' => '3600', 
  'zone' => 'example.com', 
  } 
 
 Some Returned Values
 status - success or failure
 data - object containing record_id, rdata, record_type, fqdn, and zone
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token,
  'fqdn' => 'bar.foo.test.com', 
  'rdata' => array( 'address' => '5.5.5.5' ), 
  'ttl' => '3600', 
  'zone' => 'test.com'
  )
  );
 
 echo '<b>Adding A Record to Zone Node</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('CreateARecord',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result->data); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Create A Record');
 }
 
 ?>
 
 <?php
 /* ##########################
 
 Publishing a zone
 ------------
 To commit changes and publish a zone you must send a PublishZone command with the token and zone as paramters
 
 Some Returned Values
 status - success or failure
 data - object containing serial, serial_style, zone, zone_type
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token, 
  'zone' => 'test.com'
  )
  );
 
 echo '<b>Publishing Zone</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('PublishZone',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result->data); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Publish Zone');
 }
 
 ?>
 
 <?php
 /* ##########################
 
 Get a node list under a zone
 ------------
 To get a list of nodes under a zone send a GetNodeList command with the token, zone and optional fqdn as parameters
 
 Some Returned Values
 status - success or failure
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token, 
  'zone' => 'test.com',
  )
  );
 
 echo '<b>Fetching Nodes under your Zone</b><br/>';
 echo '--------------------------<br/>';
 
  $result = $client->__soapCall('GetNodeList',$parameters);
 
 
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Fetch Zone Nodes');
 }
 
 ?>
 
 <?php
 /* ##########################
 
 Get a node list under a zone
 ------------
 To get a list of nodes under a zone send a GetNodeList command with the token, zone and optional fqdn as parameters
 
 Some Returned Values
 status - success or failure
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token, 
  'zone' => 'test.com',
  'fqdn' => 'foo.test.com'
  )
  );
 
 echo '<b>Fetching Nodes under your Zone</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('GetNodeList',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Fetch Zone Nodes');
 }
 
 ?>
 
 
 <?php
 /* ##########################
 
 Deleting a Zone node
 ------------
 To remove a zone node you must send the PruneZone command with the token and zone as paramters
 
 Some Returned Values
 status - success or failure
 data - object containing serial, serial_style, zone, zone_type
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token, 
  'fqdn' => 'foo.test.com',
  'zone' => 'test.com'
  )
  );
 
 echo '<b>Deleting Zone Node</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('PruneZone',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result->data); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Publish Zone');
 }
 
 ?>
 
 
 
 <?php
 /* ##########################
 
 Publishing a zone
 ------------
 To commit changes and publish a zone you must send a PublishZone command with the token and zone as paramters
 
 Some Returned Values
 status - success or failure
 data - object containing serial, serial_style, zone, zone_type
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token, 
  'zone' => 'test.com'
  )
  );
 
 echo '<b>Publishing Zone</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('PublishZone',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result->data); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Publish Zone');
 }
 
 ?>
 
 
 <?php
 
 /* ##########################
 
 Logging Out
 ------------
 To log in to the dynect API you must call SessionLogout with the token received at login
 
 Some Returned Values
 status - success or failure
 
 ** Complete Documentations can be found at
 https://manage.dynect.net/help/docs/api2/soap/
 
 ########################## */
 
 $parameters = array(
  'parameters' => array(
  'token'=> $token
  )
  );
 
 echo '<b>Logging Out</b><br/>';
 echo '--------------------------<br/>';
 $result = $client->__soapCall('SessionLogout',$parameters);
 
 if(is_soap_fault($result)){
  trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
  die();
 }
 
 $message = $result->msgs;
 echo $message->lvl.": ".(isset($message->err_cd) && $message->err_cd != '' ? '('.$message->err_cd.') ' : '').$message->source." - ".$message->info."<br/>";
 
 if($result->status == 'success'){
  echo '<pre>'; print_r($result); echo '</pre_v>'; # NOTE: The "_v" has been added to this tag for WordPress visibility. Remove "_v" for proper functionality of <pre_v> tag.
 } else {
  die('Unable to Log out');
 }
 
 ?>


DNS API Knowledge Base



--------------------------------------------------------------------------------




LEARN

What is Domain Name System (DNS)?

What is Cloud Networking?

Oracle DNS

RESOURCES

Dynamic DNS

Download Update Client

Internet Guide

CONTACT US

Support

Status

Community Forum

ABOUT

Legal Notices

Privacy Policy

One Oracle Drive, Nashua, NH 03062   //   Cookie-Präferenzen

Copyright © 2023, Oracle and/or its affiliates. All rights reserved. Oracle and
Java are registered trademarks of Oracle and/or its affiliates. Other names may
be trademarks of their respective owners.