Skip to content

Commit 21a36dd

Browse files
committed
Added updateAuthinfo for contacts
1 parent 3ed88e1 commit 21a36dd

4 files changed

Lines changed: 102 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ With Namingo EPP you can start small, customize as you go, and adapt it to the s
3333
| update | N/A ||| |
3434
| updateNS || N/A | N/A | |
3535
| updateContact || N/A | N/A | |
36-
| updateAuthinfo || N/A | N/A | |
36+
| updateAuthinfo || | N/A | |
3737
| updateStatus |||| |
3838
| updateDNSSEC || N/A | N/A | |
3939
| renew || N/A | N/A | |

examples/ContactUpdateAuthinfo.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Tembo EPP client test file
4+
*
5+
* Written in 2023-2025 by Taras Kondratyuk (https://namingo.org)
6+
* Based on xpanel/epp-bundle written in 2019 by Lilian Rudenco (info@xpanel.com)
7+
*
8+
* @license MIT
9+
*/
10+
11+
require_once __DIR__ . '/Connection.php';
12+
13+
try
14+
{
15+
$epp = connect();
16+
17+
$contactUpdateAuthinfo = $epp->contactUpdateAuthinfo([
18+
'id' => 'tembo007',
19+
'authInfo' => 'P@ssword123!',
20+
]);
21+
22+
if (isset($contactUpdateAuthinfo['error'])) {
23+
echo 'ContactUpdateAuthinfo Error: ' . $contactUpdateAuthinfo['error'] . PHP_EOL;
24+
return;
25+
}
26+
27+
echo "ContactUpdateAuthinfo result: {$contactUpdateAuthinfo['code']}: {$contactUpdateAuthinfo['msg']}" . PHP_EOL;
28+
29+
$logout = $epp->logout();
30+
31+
echo 'Logout Result: ' . $logout['code'] . ': ' . $logout['msg'][0] . PHP_EOL;
32+
33+
} catch (\Pinga\Tembo\Exception\EppException $e) {
34+
echo "Error : " . $e->getMessage() . PHP_EOL;
35+
exit(1);
36+
} catch (Throwable $e) {
37+
echo "Error : " . $e->getMessage() . PHP_EOL;
38+
exit(1);
39+
}

src/Epp.php

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,66 @@ public function contactUpdate($params = array())
12221222
return $return;
12231223
}
12241224

1225+
/**
1226+
* contactUpdateAuthinfo
1227+
*/
1228+
public function contactUpdateAuthinfo($params = array())
1229+
{
1230+
if (!$this->isLoggedIn) {
1231+
return array(
1232+
'code' => 2002,
1233+
'msg' => 'Command use error'
1234+
);
1235+
}
1236+
1237+
$return = array();
1238+
try {
1239+
$from = $to = array();
1240+
$from[] = '/{{ id }}/';
1241+
$to[] = htmlspecialchars($params['contactid']);
1242+
$from[] = '/{{ authInfo }}/';
1243+
$to[] = htmlspecialchars($params['authInfo']);
1244+
$from[] = '/{{ clTRID }}/';
1245+
$clTRID = str_replace('.', '', round(microtime(1), 3));
1246+
$to[] = htmlspecialchars($this->prefix . '-contact-updateAuthinfo-' . $clTRID);
1247+
$from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
1248+
$to[] = '';
1249+
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1250+
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
1251+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1252+
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
1253+
<command>
1254+
<update>
1255+
<contact:update
1256+
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
1257+
<contact:id>{{ id }}</contact:id>
1258+
<contact:chg>
1259+
<contact:authInfo>
1260+
<contact:pw>{{ authInfo }}</contact:pw>
1261+
</contact:authInfo>
1262+
</contact:chg>
1263+
</contact:update>
1264+
</update>
1265+
<clTRID>{{ clTRID }}</clTRID>
1266+
</command>
1267+
</epp>');
1268+
$r = $this->writeRequest($xml);
1269+
$code = (int)$r->response->result->attributes()->code;
1270+
$msg = (string)$r->response->result->msg;
1271+
1272+
$return = array(
1273+
'code' => $code,
1274+
'msg' => $msg
1275+
);
1276+
} catch (\Exception $e) {
1277+
$return = array(
1278+
'error' => $e->getMessage()
1279+
);
1280+
}
1281+
1282+
return $return;
1283+
}
1284+
12251285
/**
12261286
* contactUpdateStatus
12271287
*/
@@ -1670,7 +1730,7 @@ public function domainCheckFee($params = array())
16701730
$to[] = $feeExtXml;
16711731
$from[] = '/{{ clTRID }}/';
16721732
$microtime = str_replace('.', '', round(microtime(1), 3));
1673-
$to[] = htmlspecialchars($this->prefix . '-domain-checkClaims-' . $microtime);
1733+
$to[] = htmlspecialchars($this->prefix . '-domain-checkFee-' . $microtime);
16741734
$from[] = "/<\w+:\w+>\s*<\/\w+:\w+>\s+/ims";
16751735
$to[] = '';
16761736
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>

src/EppRegistryInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function contactCheck(array $params);
3232
public function contactInfo(array $params);
3333
public function contactCreate(array $params);
3434
public function contactUpdate(array $params);
35+
public function contactUpdateAuthinfo(array $params);
3536
public function contactUpdateStatus(array $params);
3637
public function contactDelete(array $params);
3738
public function contactTransfer(array $params);

0 commit comments

Comments
 (0)