-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathcreatecontact.php
54 lines (48 loc) · 1.74 KB
/
createcontact.php
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
45
46
47
48
49
50
51
52
53
54
<?php
require('../autoloader.php');
use Metaregistrar\EPP\eppConnection;
use Metaregistrar\EPP\eppException;
use Metaregistrar\EPP\eppContactPostalInfo;
use Metaregistrar\EPP\eppContact;
use Metaregistrar\EPP\eppCreateContactRequest;
/**
* This code example creates a contact object with a registry
*/
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()) {
createcontact($conn, 'info@test.com', '+31.201234567', 'Domain Administration', 'Metaregistrar', 'Address 1', 'Zipcode', 'City', 'NL');
$conn->logout();
}
}
} catch (eppException $e) {
echo "ERROR: " . $e->getMessage() . "\n\n";
}
/**
* @param $conn eppConnection
* @param $email string
* @param $telephone string
* @param $name string
* @param $organization string
* @param $address string
* @param $postcode string
* @param $city string
* @param $country string
* @return null
*/
function createcontact($conn, $email, $telephone, $name, $organization, $address, $postcode, $city, $country) {
$postalinfo = new eppContactPostalInfo($name, $city, $country, $organization, $address, null, $postcode);
$contactinfo = new eppContact($postalinfo, $email, $telephone);
$contactinfo->setPassword('');
$contact = new eppCreateContactRequest($contactinfo);
if ($response = $conn->request($contact)) {
/* @var $response Metaregistrar\EPP\eppCreateContactResponse */
echo "Contact created on " . $response->getContactCreateDate() . " with id " . $response->getContactId() . "\n";
return $response->getContactId();
} else {
echo "Create contact failed";
}
return null;
}