Skip to content

Commit 9c41a12

Browse files
author
Jessica Smith
committed
Update README.md
1 parent 14e975d commit 9c41a12

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The easiest way to install and use this client library is using Composer. The fo
1717
composer require tiggee/dnsmadeeasy-client
1818
```
1919

20-
## Usage
20+
## Getting Started
2121

2222
You will need a DNS Made Easy account and API credentials. You can get an account at the [DNS Made Easy website](https://www.dnsmadeeasy.com). There is an API sandbox available, you can create a [new account here](https://sandbox.dnsmadeeasy.com/account/new).
2323

@@ -45,6 +45,44 @@ You can tell the client to use the sandbox API endpoint by using the `setEndpoin
4545
$client->setEndpoint('https://api.sandbox.dnsmadeeasy.com/V2.0');
4646
```
4747

48+
### Putting it all together
49+
50+
Putting this together, it's time for the API equivalent of Hello World. Let's get a list of your domains.
51+
52+
```php
53+
<?php
54+
// Load the library and dependencies
55+
require_once 'vendor/_autoload.php';
56+
57+
// Create a new client and set our credentials
58+
$client = new \DnsMadeEasy\Client;
59+
$client->setApiKey("Your API Key");
60+
$client->setSecretKey("Your Secret Key");
61+
62+
// Configure it to use the Sandbox
63+
$client->setEndpoint('https://api.sandbox.dnsmadeeasy.com/V2.0');
64+
65+
// Create a new domain
66+
$domain = $client->domains->create();
67+
$domain->name = 'mydomain.example.com';
68+
$domain->save();
69+
70+
// Print out our domain
71+
echo json_encode($domain, JSON_PRETTY_PRINT);
72+
73+
// Now fetch a list of our domains
74+
$domains = $client->domains->paginate();
75+
foreach ($domains as $domain) {
76+
echo json_encode($domain, JSON_PRETTY_PRINT);
77+
}
78+
```
79+
80+
There's more examples further down of using the API client SDK.
81+
82+
## Configuration
83+
84+
There's additional configuration options you can use with the client as well as just specifying the sandbox.
85+
4886
### Logging
4987

5088
You can specify a logger that implements the [PSR-3 Logger](https://www.php-fig.org/psr/psr-3/) specification such as MonoLog. The client is a `LoggerAwareInterface` and the logger can be specified either in the constructor or via a method call.
@@ -131,7 +169,7 @@ $domain = $client->domains->get(1234);
131169
$domain->delete();
132170
```
133171

134-
### Full Example
172+
### Creating a domain and records
135173

136174
This example creates a new domain and adds records to it.
137175

0 commit comments

Comments
 (0)