<?php // Autoload the library using Composer, if you're using a framework you shouldn't need to do this!! require_once '../vendor/autoload.php'; use Ballen\Dodns\CredentialManager; use Ballen\Dodns\Dodns; /** * Example of deleting a domain */ // We now create an instance of the DigitalOcean DNS client passing in our API credentials. $dns = new Dodns(new CredentialManager(file_get_contents('token.txt'))); // Set the domain entity that we wish to delete from our account... $domain = new \Ballen\Dodns\Entities\Domain(); $domain->setName('mytestdodmain.uk'); // Now we carry out the deletion and check if it was successful... if (!$dns->deleteDomain($domain)) { echo "An error occured and the domain could not be deleted!"; } else { echo sprintf("Congratulations, the domain <strong>%s</strong> has been deleted successfully!", $domain->getName()); }
<?php // Autoload the library using Composer, if you're using a framework you shouldn't need to do this!! require_once '../vendor/autoload.php'; use Ballen\Dodns\CredentialManager; use Ballen\Dodns\Dodns; /** * Example of getting details of a single record. */ // We now create an instance of the DigitalOcean DNS client passing in our API credentials. $dns = new Dodns(new CredentialManager(file_get_contents('token.txt'))); // Set the domain entity that the record exists against... $domain = new \Ballen\Dodns\Entities\Domain(); $domain->setName('mytestdomain.uk'); // Provide the record ID that you wish to get the details of (if you don't know this, call the records() method first, see the 'get_all_records_for_a_domain.php' example file!) $record_id = 9013589; // You can now access the record details... $record = $dns->record($domain, $record_id); // Want to inspect the data? //var_dump($record); // Access the entity properties using the 'getX' methods... echo "Record type: " . $record->getType() . "<br>"; echo "Record name: " . $record->getName() . "<br>"; echo "Record data (eg. Server IP for a 'A' record): " . $record->getData() . "<br>";
<?php // Autoload the library using Composer, if you're using a framework you shouldn't need to do this!! require_once '../vendor/autoload.php'; use Ballen\Dodns\CredentialManager; use Ballen\Dodns\Dodns; /** * Example of deleting a domain record. */ // We now create an instance of the DigitalOcean DNS client passing in our API credentials. $dns = new Dodns(new CredentialManager(file_get_contents('token.txt'))); // Set the domain entity that the record exists against... $domain = new \Ballen\Dodns\Entities\Domain(); $domain->setName('mytestdomain.uk'); // Provide the record ID that you wish to delete (if you don't know this, call the records() method first, see the 'get_all_records_for_a_domain.php' example file!) $record_id = 9012666; // Now we carry out the deletion and check if it was successful... if (!$dns->deleteRecord($domain, $record_id)) { echo "An error occured and the domain record could not be deleted!"; } else { echo sprintf("Congratulations, the domain record has been deleted successfully!"); }
<?php // Autoload the library using Composer, if you're using a framework you shouldn't need to do this!! require_once '../vendor/autoload.php'; use Ballen\Dodns\CredentialManager; use Ballen\Dodns\Dodns; /** * Example of creating a new record. */ // We now create an instance of the DigitalOcean DNS client passing in our API credentials. $dns = new Dodns(new CredentialManager(file_get_contents('token.txt'))); // Set the domain of which we are saving the new record against.... $domain = new Ballen\Dodns\Entities\Domain(); $domain->setName('mytestdomain.uk'); // Using the RecordBuilder class we create our record before saving it to the domain via. the API... $new_record = new Ballen\Dodns\Support\RecordBuilder('A', 'server2', '80.1.1.1'); // Now we carry out the creation and check if it was successful... $record = $dns->createRecord($domain, $new_record); if ($record) { echo "Congratulations, the record <strong>{$record->getName()}.{$domain->getName()}</strong> has been created successfully!"; }