theprivateer / domainr
Domainr API 的 PHP 封装。
v0.1.3
2017-07-28 04:43 UTC
Requires
- php: >=5.5.9
- guzzlehttp/guzzle: ^6.3
This package is not auto-updated.
Last update: 2024-09-29 03:36:36 UTC
README
Domainr API 的 PHP 封装。
安装
可以使用 Composer 安装此包。
composer require theprivateer/domainr
用法
有关详细文档,请访问 Mashape 上的 Domainr API 或 Domainr.build 上的 Domainr API。您需要订阅 Domainr API 以获取 Mashape API 密钥 - 目前有一个每月允许 10,000 次请求的免费计划,但您需要输入信用卡详细信息以支付任何超额费用。
// autoload include 'path/to/autoload.php' $client = new \Privateer\Domainr\Domainr('YOUR_MASHAPE_API_KEY');
搜索
$client->search($query, $location = null, $registrar = null, $defaults = null);
搜索方法允许您通过关键词搜索域名,并从 Domainr 获取多个替代方案。
$client->search('acme.coffee');
将返回 JSON 数据
[ { "domain":"acme.coffee", "host":"", "subdomain":"acme.", "zone":"coffee", "path":"", "registerURL":"https:\/\/api.domainr.com\/v2\/register?client_id=mashape-salimgrsy&domain=acme.coffee®istrar=&source=" }, { "domain":"acme.cafe", "host":"", "subdomain":"acme.", "zone":"cafe", "path":"", "registerURL":"https:\/\/api.domainr.com\/v2\/register?client_id=mashape-salimgrsy&domain=acme.cafe®istrar=&source=" }, { "domain":"acme.com.tr", "host":"", "subdomain":"acme.", "zone":"com.tr", "path":"", "registerURL":"https:\/\/api.domainr.com\/v2\/register?client_id=mashape-salimgrsy&domain=acme.com.tr®istrar=&source=" } ]
注册
$client->register($domain, $registrar = null);
此方法返回一个字符串,其值是域注册商的 URL。
$client->register('acme.coffee'); // https://domains.google.com/registrar?s=acme.coffee&utm_campaign=domainr.com&utm_content=&af=domainr.com
状态
$client->status($domain);
状态方法允许您检查域名是否可用。
$status = $client->status('acme.coffee');
这将返回一个 \Privateer\Domainr\Status
实例。底层 JSON 响应的值将通过 Status
对象上的 get()
方法访问。
$status = $client->status('acme.coffee'); $status->get('domain'); // acme.coffee $status->get('zone'); // coffee $status->get('status'); // undelegated inactive $status->get('summary'); // inactive
Status
对象具有许多实用助手来进一步解释响应。
$status->get('description'); // Available for new registration. $status->get('available'); // true
这些动态属性是从 Domainr API 文档中的 状态描述 中派生出来的。
Status
对象还有一个静态方法来访问这些值。
Status::description($summary);
\Privateer\Domainr\Status::description('inactive'); // Available for new registration. \Privateer\Domainr\Status::available('inactive'); // true