forked from metaregistrar/php-epp-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatehost.php
More file actions
44 lines (37 loc) · 1.11 KB
/
createhost.php
File metadata and controls
44 lines (37 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require('../autoloader.php');
use Metaregistrar\EPP\eppConnection;
use Metaregistrar\EPP\eppException;
use Metaregistrar\EPP\eppHost;
use Metaregistrar\EPP\eppCreateHostRequest;
if ($argc <= 1) {
echo "Usage: createhost.php <hostname>\n";
echo "Please a host name to create\n\n";
die();
}
$hostname = $argv[1];
try {
// Please enter your own settings file here under before using this example
if ($conn = eppConnection::create('')) {
// Connect to the EPP server
if ($conn->login()) {
createhost($conn, $hostname);
$conn->logout();
}
}
} catch (eppException $e) {
echo "ERROR: " . $e->getMessage() . "\n\n";
}
/**
* @param $conn eppConnection
* @param $hostname string
* @return null
*/
function createhost($conn, $hostname) {
$create = new eppCreateHostRequest(new eppHost($hostname));
if ($response = $conn->request($create)) {
/* @var $response Metaregistrar\EPP\eppCreateHostResponse */
echo "Host created on " . $response->getHostCreateDate() . " with id " . $response->getHostName() . "\n";
}
return null;
}