Browse Source

Add domainkey auth.

Shane Mc Cormack 8 years ago
parent
commit
af75f8ba6f
1 changed files with 15 additions and 0 deletions
  1. 15 0
      src/MyDNSHostAPI.php

+ 15 - 0
src/MyDNSHostAPI.php

@@ -75,6 +75,18 @@
 			return $this;
 		}
 
+		/**
+		 * Auth using a domain and domain key.
+		 *
+		 * @param $domain Domain to auth with
+		 * @param $key Key to auth with
+		 * @return $this for chaining.
+		 */
+		public function setAuthDomainKey($domain, $key) {
+			$this->auth = ['type' => 'domainkey', 'domain' => $domain, 'key' => $key];
+			return $this;
+		}
+
 		/**
 		 * Auth using a session ID.
 		 *
@@ -616,6 +628,9 @@
 				} else if ($this->auth['type'] == 'userkey') {
 					$headers['X-API-USER'] = $this->auth['user'];
 					$headers['X-API-KEY'] = $this->auth['key'];
+				} else if ($this->auth['type'] == 'domainkey') {
+					$headers['X-DOMAIN'] = $this->auth['domain'];
+					$headers['X-DOMAIN-KEY'] = $this->auth['key'];
 				} else if ($this->auth['type'] == 'userpass') {
 					$options['auth'] = [$this->auth['user'], $this->auth['pass']];
 					if (isset($this->auth['2fa'])) {