pandi-id / php-epp-id
PHP的EPP(可扩展提供协议)TCP/SSL客户端
1.0.2
2019-12-18 14:10 UTC
Requires
- php: >=5.5.0
- ext-intl: *
- ext-openssl: *
- guzzlehttp/guzzle: ^6.3
- php-coveralls/php-coveralls: ^2.1
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-05 13:40:57 UTC
README
这是从AfriCC修改过的文件
php-epp-id是一个使用现代PHP编写的EPP(可扩展提供协议)TCP/SSL客户端
在GPLv3许可下发布,欢迎贡献(分支,创建有意义的分支名称,使用该分支名称提交pull request)!
要求
- PHP 5.5+
- php-ext-intl
- php-ext-openssl
功能
- 现代PHP标准
- 高级用法(即插即用)
- 简化客户端(自动登录/注销,自动注入clTRID)
- SSL(+本地证书)
- 类似于XPath的设置器,以简化复杂XML结构的创建
- 基于XML的响应,可以直接通过XPath进行遍历
- RFC 5730, RFC 5731, RFC 5732, RFC 5733, RFC 5734 & RFC 3915
安装
通过Composer
$ composer require pandi-id/php-epp-id
用法
查看示例文件夹,以获取更完整的使用参考。
基本客户端连接
这将自动在连接时登录,并在关闭时注销
<?php require 'vendor/autoload.php'; use Pandi\EPP\Client as EPPClient; $epp_client = new EPPClient([ 'host' => 'epptest.org', 'username' => 'foo', 'password' => 'bar', 'services' => [ 'urn:ietf:params:xml:ns:domain-1.0', 'urn:ietf:params:xml:ns:contact-1.0' ], 'debug' => true, ]); try { $greeting = $epp_client->connect(); } catch(Exception $e) { echo $e->getMessage() . PHP_EOL; unset($epp_client); exit(1); } $epp_client->close();
创建框架对象
setXXX()表示值只能设置一次,重新调用该方法将覆盖之前的值。
addXXX()表示可以存在多个值,重新调用该方法将添加值。
<?php require 'vendor/autoload.php'; use Pandi\EPP\Frame\Command\Create\Host as CreateHost; $frame = new CreateHost; $frame->setHost('ns1.example.com'); $frame->setHost('ns2.example.com'); $frame->addAddr('8.8.8.8'); $frame->addAddr('8.8.4.4'); $frame->addAddr('2a00:1450:4009:809::1001'); echo $frame; // or send frame to previously established connection $epp_client->sendFrame($frame);
解析响应
您可以通过传递xpath直接访问节点,或者使用data()方法,它将返回一个关联数组。
use Pandi\EPP\Frame\Command\Check\Domain as DomainCheck; use Pandi\EPP\Frame\Response; $frame = new DomainCheck; $frame->addDomain('example.org'); $frame->addDomain('example.net'); $frame->addDomain('example.com'); $response = $epp_client->request($frame); if (!($response instanceof Response)) { echo 'response error' . PHP_EOL; unset($epp_client); exit(1); } echo $response->code() . PHP_EOL; echo $response->message() . PHP_EOL; echo $response->clientTransactionId() . PHP_EOL; echo $response->serverTransactionId() . PHP_EOL; $data = $response->data(); if (empty($data) || !is_array($data)) { echo 'empty response data' . PHP_EOL; unset($epp_client); exit(1); } foreach ($data['chkData']['cd'] as $cd) { printf('Domain: %s, available: %d' . PHP_EOL, $cd['name'], $cd['@name']['avail']); }
鸣谢
许可证
php-epp-id在GPLv3许可证下发布。有关详细信息,请参阅附带LICENSE文件。