adzon/namesilo-composer
Composer 安装命令:
composer require adzon/namesilo-composer
包简介
Use Namesilo Api In Laravel
README 文档
README
Use Namesilo Api In Laravel
Simple PHP SDK for registering domain names using Namesilo.com.
Dependencies
- php-xml package.
Install in Debian:
sudo aptitude install php7.0-xml
Quick start
Create an instance of the Namesilo class.
To receive a sandbox API key for testing, please contact namesilo.
#### create a Namesilo object with production key $ns = new Namesilo('your api key'); #### create a Namesilo object with sandox key $ns = new Namesilo('your api key',true); #### turn Debugging on (if you want to fix an issue with this library) $ns = new Namesilo('your api key',true,true); #### Simple usage try{ $ns->is_domain_available('example.com'); }catch(Exception $e){ #### print error message echo $e->getMessage(); }
Debugging
To enable debugging edit namesilo.php provide a third argument to Namesilo() and set it to tre.
$ns = new Namesilo('your api key',true,true);
Once enabled, all functions (methods) print_r() their request and return value.
never turn debugging on in production.
Usage example
Retrieve the lock status for exmaple.com
try{ $lock_status = $ns->lock_status('example.com'); }catch(Exception $e){ echo $e->getMessage(); } if($lock_status){ echo 'domain is lock'; }else{ echo 'domain is unlock'; }
List of methods
NOTE: make sure that you capture possible errors with a
try {} catch {}as shown in the above examples.
- create_contact(): create a new contact id. Used for new domain registration.
- delete_contact(): useful for deleting a contact if registration fails
- register_domain_by_contact_id()
- register_domain(): create a new contact id and register domain at once (not recommended)
- update_nameservers()
- update_contact_by_domain()
- add_dns_record()
- get_dns_records(): returns an array of dns records
- delete_dns_record()
- is_domain_available()
- send_auth_code(): Have the EPP transfer code for the domain emailed to the administrative contact.
- get_contact_by_id()
- list_domains()
- get_nameservers()
- privacy_status()
- add_privacy()
- remove_privacy()
- get_domain_info()
- get_account_balance()
create_contact()
Use this function to create a new contact-id and then use the contact-id retuned by this function to associate it with a new domain registration.
returns created contact id on success and false on failure.
$contact_id = $ns->create_contact( $fn, // first name $ln, // last name $ad, // address $cy, // city $st, // state $zp, // zip $ct, // country $em, // email $ph // phone );
register_domain_by_contact_id()
returns true on success and false on failure.
$result = $ns->register_domain_by_contact_id($domain,$contact_id,$years=1);
This function will automatically attemp to delete the contact if registration fails.
Default profile and profiles that are associated with any active domains cannot be deleted.
register_domain()
Create a new contact-id and register a domain for it at once. This method is not recommended.
returns true on success and false on failure.
$ns->register_domain( $domain, // example.com $fn, // first name $ln, // last name $ad, // address $cy, // city $st, // state $zp, // zip $ct, // country $em, // email $ph, // phone $years = 1 );
update_contact_by_domain()
returns true on success and false on failure.
$contact_id = $ns->update_contact_by_domain( $domain, // example.com $fn, // first name $ln, // last name $ad, // address $cy, // city $st, // state $zp, // zip $ct, // country $em, // email $ph // phone );
update_nameservers()
Change the NameServers associated with one of your domains.
returns true on success and false on success and false on failure.
$result = $ns->update_nameservers('example.com','ns1.namesilo.com','ns2.namesilo.com');
delete_contact()
returns true on success and false on failure.
$ns->delete_contact($contact_id);
Please remember that the only contact profiles that can be deleted are those that are not the account default and are not associated with any active domains or order profiles.
add_dns_record()
returns true on success and false on failure.
$ns->add_dns_record($domain,$type,$host,$value,$distance='',$ttl='');
$type possible values are "A", "AAAA", "CNAME", "MX" and "TXT"
$host The hostname for the new record (there is no need to include the ".DOMAIN")
$value
- A - The IPV4 Address
- AAAA - The IPV6 Address
- CNAME - The Target Hostname
- MX - The Target Hostname
- TXT - The Text
$distance: Only used for MX (default is 10 if not provided)
$ttl: The TTL for the new record (default is 7207 if not provided)
get_dns_records()
returns an array of records on success and false on failure.
$ns->get_dns_records($domain);
Sample print_r() of successfull return value:
Again, make sure you capture exceptions.
Array
(
[0] => Array
(
[record_id] => a8c4251d3c3d114d70d48dcaf0288257
[type] => A
[host] => sunsed-test15.com
[value] => 173.255.255.106
[ttl] => 7200
[distance] => 0
)
)
delete_dns_record()
returns true on success and false on failure.
$ns->delete_dns_record($domain,$record_id);
is_domain_available()
possible return values: 'available', 'invalid', 'unavailable' and false.
try{ $result = $ns->is_domain_available($domain); if($result == 'available'){ echo 'domain is available'; }elseif($result == 'invalid'){ echo 'pleas check your domain'; }elseif($result == 'unavailable'){ echo 'domain is not available'; }else{ echo 'failed'; } }catch(Exception $e){ echo $e->getMessage(); }
send_auth_code()
returns true on success and false on failure.
ns->send_auth_code($domain);
get_contact_by_id()
returns contact info on success and false on failure.
$ns->get_contact_by_id($contact_id);
list_domains()
returns an array of domains on success and false on failure.
try{ $result = $ns->list_domains(); if($result){ echo 'success'; }else{ echo 'failed'; } }catch(Exception $e){ echo $e->getMessage(); }
Sample return value:
Array
(
[0] => sunsed-test12.com
[1] => sunsed-test13.com
[2] => sunsed-test15.com
)
get_nameservers()
returns an array of nameservers on success and false on failure.
Sample return value:
Array
(
[0] => NS1.NAMESILO.COM
[1] => NS2.NAMESILO.COM
)
Note: Namesilo returns the namesevrers in capital letters.
privacy_status()
Retrieves the privacy status.
$result = $ns->privacy_status($domain); if($result) echo 'Privacy is enabled'; else echo 'Privacy is disabled';
add_privacy()
$result = $ns->add_privacy($domain);
remove_privacy()
$result = $ns->remove_privacy($domain);
get_domain_info()
returns domain-info-array on success and false on failure.
$ns->get_domain_info($domain);
Sample return value:
Array
(
[code] => 300
[detail] => success
[created] => 2015-02-06
[expires] => 2016-02-06
[status] => Active
[locked] => Yes
[private] => Yes
[auto_renew] => No
[traffic_type] => Custom DNS
[forward_url] => N/A
[forward_type] => N/A
[nameservers] => Array
(
[nameserver] => Array
(
[0] => NS1.NAMESILO.COM
[1] => NS2.NAMESILO.COM
)
)
[contact_ids] => Array
(
[registrant] => 903
[administrative] => 903
[technical] => 903
[billing] => 903
)
)
get_account_balance()
returns account balance on success and false on failure.
$result = $ns->get_account_balance();
adzon/namesilo-composer 适用场景与选型建议
adzon/namesilo-composer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 161 次下载、GitHub Stars 达 4, 最近一次更新时间为 2018 年 11 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「laravel」 「namesilo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 adzon/namesilo-composer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 adzon/namesilo-composer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 adzon/namesilo-composer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Alfabank REST API integration
PHP SDK for NameSilo API
NameSilo API Bundle for Symfony - Enterprise-grade domain registrar integration
Unified PHP Registrar API (NameSilo, GoDaddy, Namecheap, Dynadot) with pluggable adapters.
Laravel package for Accurate Online API integration.
统计信息
- 总下载量: 161
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2018-11-24