定制 heximcz/api-wrapper-webglobe 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

heximcz/api-wrapper-webglobe

最新稳定版本:1.0.0

Composer 安装命令:

composer require heximcz/api-wrapper-webglobe

包简介

PHP wrapper for Webglobe REST API

README 文档

README

Install

composer require heximcz/api-wrapper-webglobe

Examples

GET domain info by name

use Webglobe\ApiWebglobe;
use Webglobe\Exceptions\ApiWebglobeException;
use Webglobe\Exceptions\ApiWebglobeResponseException;

$production = false; 
$login = "login";
$password = "password";

try {
    // URL
    $api_url = "https://api." . ($production ? "" : "staging.") . "webglobe.com";

    $api = new ApiWebglobe($api_url, $login, $password);

    // get domain info
    $api->domainInfoByName("example.com");

    var_dump($api->getResponse());

} catch (ApiWebglobeException $e) {
    // CURL or JSON decode errors
    if (isset($api)) {
        var_dump($api->getResponse());
        var_dump($api->getReturnCode());
    }
    echo "API error occurred: " . $e->getMessage();
} catch (ApiWebglobeResponseException $e) {
    // Handle response errors (return code >= 400)
    if (isset($api)) {
        var_dump($api->getResponse());
        var_dump($api->getReturnCode());
    }
    echo "API error occurred: " . $e->getMessage();
}

Register new FO contact

use Webglobe\ApiWebglobe;
use Webglobe\Exceptions\ApiWebglobeException;
use Webglobe\Exceptions\ApiWebglobeResponseException;
use Webglobe\Payloads\Contact;

$production = false; 
$login = "login";
$password = "password";

try {
    // URL
    $api_url = "https://api." . ($production ? "" : "staging.") . "webglobe.com";

    $api = new ApiWebglobe($api_url, $login, $password);

    // Prepare payload for contact data
    // in this case is used 'FO'
    $contact = new Contact();
    $contact->setAction("create")
        ->setSingleTld("cz")
        ->setLegalForm("FO")
        ->setStreet("Street 1")
        ->setTown("City")
        ->setPostcode("11150")
        ->setCountry("CZ")
        ->setEmail("example@example.com")
        ->setContactName("John Doe")
        ->setLang("cs")
        ;

    // echo $contact->toJson();
    // var_dump($contact->toArray());
    // die;

    $api->contactCreate($contact->toArray());

    // show response
    var_dump($api->getResponse());

    // Get info about new crated contact
    $contact_create_response = $api->getResponse();
    if ($contact_create_response["success"]){
        $api->contactDetailById($contact_create_response["contact_id"]);

        // show response
        var_dump($api->getResponse());
    }

} catch (ApiWebglobeException $e) {
    // CURL or JSON decode errors
    if (isset($api)) {
        var_dump($api->getResponse());
        var_dump($api->getReturnCode());
    }
    echo "API error occurred: " . $e->getMessage();
} catch (ApiWebglobeResponseException $e) {
    // Handle response errors (return code >= 400)
    if (isset($api)) {
        var_dump($api->getResponse());
        var_dump($api->getReturnCode());
    }
    echo "API error occurred: " . $e->getMessage();
}

Payload for order

$domain = "example.com";
$tld = "com";

// only "registration" method is implemented for now
$order = new Order("registration");

$order->setPaymentType("credit")
      ->setDomainName($domain)
      ->setPeriod(12)
      ->setIdRegistrant(<int>)
      ->setIdRegistrantAdmin(<int>)
      ;

switch ($tld) {
    case "cz":
        // NSSET ID for CZ domain:
        $order->setDnsType("G")
              ->setNssetId("<YOUR:NSSET-NAME-FOR-CZ>")
              ->setGroupId(<int>);
        break;
    default:
        // Nameservers group ID for other TLDs
        $order->setDnsType("G")
              ->setGroupId(<int>);
        break;
}

// show payload in json or array
echo $order->toJson();
var_dump($order->toArray());

Implemented Methods

This wrapper was primarily developed for domain registration and renewal, so it implements only the following methods from the entire API. However, it can be easily extended to include additional methods if needed.

  • myAccount
  • checkDomainDAS
  • checkDomain
  • listAllTLD
  • checkAvailableNicId
  • listOfRegistrants
  • contactCreate
  • contactsList
  • contactDetailById
  • contactCreateInfo
  • domainInfoByName
  • domainContacts
  • domainRegistrationInfo
  • order
  • detailOrderById
  • dnsNssetList
  • dnsNssetShowById
  • nameserversInfo
  • nameserversGroupList
  • nameserversGroupShow
  • listAllDomains
  • sendAuthCode
  • invoiceDetailById
  • invoicePayByCredit
  • servicesList
  • serviceUpdateById

License MIT

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-19