ပွင့်လင်းရင်းမြစ် PHP

Registrar API

NameSilo, GoDaddy, Namecheap နှင့် Dynadot တွင် ဒိုမိန်းများ စီမံခန့်ခွဲရန် PHP လိုင်ဘရီ တစ်ခုတည်း — အပြင် zone, DNS နှင့် cache အတွက် Cloudflare adapter ပါဝင်သည်။ ရရှိနိုင်မှု စစ်ဆေးခြင်း၊ မှတ်ပုံတင်ခြင်း၊ သက်တမ်းတိုးခြင်း၊ လွှဲပြောင်းခြင်း၊ DNS မှတ်တမ်းများနှင့် nameserver များ အားလုံးကို တသမတ်တည်း interface တစ်ခုဖြင့် ဆောင်ရွက်နိုင်သည်။

composer require josuamarcelc/registrar-api

Adapter များ

ပံ့ပိုးထားသော မှတ်ပုံတင်သူများ

Adapter ကို ဘရန်းအမည်ဖြင့် ရွေးပါ။ Adapter အားလုံးသည် တူညီသော method signature များကို မျှဝေသုံးသဖြင့် ကုဒ်ကို ပြန်မရေးဘဲ မှတ်ပုံတင်သူများကို ပြောင်းလဲနိုင်သည်။

NameSilo'namesilo'
GoDaddy'godaddy'
Namecheap'namecheap'
Dynadot'dynadot'
CloudflareDNS / zones

တိုက်ရိုက် သရုပ်ပြမှု

ဒိုမိန်း ရရှိနိုင်မှု စစ်ဆေးပါ

ဆာဗာဘက်တွင် NameSilo adapter မှတစ်ဆင့် အစစ်အမှန် checkAvailability() ခေါ်ဆိုမှုကို လုပ်ဆောင်သည်။ ဒိုမိန်း ၁၀ ခုအထိ ကော်မာ၊ space သို့မဟုတ် စာကြောင်းအသစ်ဖြင့် ခြားပြီး ထည့်ပါ။ ၅ မိနစ်လျှင် ၁၀ ကြိမ်သာ ကန့်သတ်ထားသည်။

အမြန် စတင်ရန်

အလုပ်လုပ်သော ခေါ်ဆိုမှုအတွက် သုံးကြောင်း

<?php
require __DIR__ . '/vendor/autoload.php';

use RegistrarAPI\RegistrarAPI;

$api = RegistrarAPI::make('namesilo', [
  'api_key' => 'YOUR_NAMESILO_API_KEY'
]);

$result = $api->checkAvailability(['example.com', 'mybrand.io']);
print_r($result);

အထောက်အထားများ

Adapter အလိုက် ဖွဲ့စည်းမှု

Adapter တစ်ခုစီသည် config array တစ်ခုကို လက်ခံသည်။ အောက်တွင် သင် အများအားဖြင့် လိုအပ်သည့် အနည်းဆုံးကို ဖော်ပြထားသည်။

NameSilo
RegistrarAPI::make('namesilo', [
  'api_key' => 'YOUR_KEY',
]);
GoDaddy
RegistrarAPI::make('godaddy', [
  'api_key'    => 'KEY',
  'api_secret' => 'SECRET',
  // optional: 'base' => 'https://api.godaddy.com/v1'
]);
Namecheap
RegistrarAPI::make('namecheap', [
  'api_user'  => 'USERNAME',
  'api_key'   => 'KEY',
  'client_ip' => 'SERVER_PUBLIC_IP',
  // optional: 'base' => 'https://api.namecheap.com/xml.response'
]);
Dynadot
RegistrarAPI::make('dynadot', [
  'api_key' => 'KEY',
]);

Method များ

အသုံးများသော လုပ်ဆောင်ချက်များ

Adapter တိုင်းသည် တူညီသော method signature များကို အကောင်အထည်ဖော်သည်။ ပြန်ပေးသည့် တန်ဖိုးများသည် ပုံမှန်ပြုလုပ်ထားသော associative array များ ဖြစ်သည်။

// Availability
$api->checkAvailability(['example.com']);

// Lifecycle
$api->registerDomain('example.com', [
  'years'      => 1,
  'privacy'    => true,
  'auto_renew' => true,
  'registrant' => [ /* contact fields */ ],
]);
$api->renewDomain('example.com', 1);
$api->transferDomain('example.com', ['auth_code' => 'EPP']);
$api->getDomain('example.com');

// DNS records
$api->getDNS('example.com');
$api->setDNS('example.com', [
  ['type'=>'A',    'host'=>'@',   'value'=>'203.0.113.10', 'ttl'=>600],
  ['type'=>'CNAME','host'=>'www', 'value'=>'@',            'ttl'=>600],
]);
$api->addDNS('example.com', ['type'=>'TXT','host'=>'@','value'=>'v=spf1 -all','ttl'=>300]);
$api->delDNS('example.com', ['type'=>'TXT','host'=>'@']);

// Nameservers
$api->setNameServers('example.com', ['ns1.host.com','ns2.host.com']);

// Escape hatch — call any raw endpoint the adapter doesn't wrap
$api->raw('domains/suggestions?query=mybrand&limit=5');

တုံ့ပြန်မှု ပုံသဏ္ဌာန်

သင် ရရှိမည့်အရာ

okbool — အောင်မြင်မှုကို အမြန်စစ်ဆေးရန်
rawမှတ်ပုံတင်သူ၏ မူရင်း ခွဲခြမ်းပြီး payload (JSON သို့မဟုတ် XML-မှ-array)
httpရရှိနိုင်သည့်အခါ HTTP status code
errtransport အဆင့် error string (ခေါ်ဆိုမှု မအောင်မြင်သည့်အခါသာ)
available / unavailable / invalidcheckAvailability() မှ ဖြည့်ပေးသော bucket များ
recordsgetDNS() မှ ပြန်ပေးသော {type,host,value,ttl,prio?} array

အပိုဆု

Cloudflare adapter

လိုင်ဘရီ တူ၊ ပုံသဏ္ဌာန် တူ၊ သို့သော် zone, DNS မှတ်တမ်း, cache ရှင်းလင်းခြင်းနှင့် အခမဲ့ toggle များ (Always HTTPS, Auto HTTPS Rewrites, Brotli, Minify, Rocket Loader, Dev Mode) အတွက် ဖြစ်သည်။

$cf = RegistrarAPI::make('cloudflare', ['api_token' => 'CF_TOKEN']);
$cf->createZone('example.com');
$cf->setDNS('example.com', [
  ['type'=>'A','host'=>'@','value'=>'198.51.100.10','ttl'=>300,'proxied'=>true],
]);
$cf->purgeEverything('example.com');

ပံ့ပိုးရန်

မှတ်ပုံတင်သူ အသစ်ကို ဖိုင်တစ်ခုတည်းတွင် ထည့်ပါ

src/adapters/ တွင် BaseAdapter ကို ဆက်ခံသော class တစ်ခု ဖန်တီးပြီး abstract method များကို အကောင်အထည်ဖော်ပါ။ Composer က အလိုအလျောက် ရယူပါလိမ့်မည်။

namespace RegistrarAPI\Adapters;

use RegistrarAPI\Core\BaseAdapter;

class MyRegistrar extends BaseAdapter {
  protected string $brand = 'myregistrar';

  public function checkAvailability(array $domains): array { /* ... */ }
  public function registerDomain(string $domain, array $opts): array { /* ... */ }
  public function renewDomain(string $domain, int $years=1, array $opts=[]): array { /* ... */ }
  public function transferDomain(string $domain, array $opts): array { /* ... */ }
  public function getDomain(string $domain): array { /* ... */ }
  public function getDNS(string $domain): array { /* ... */ }
  public function setDNS(string $domain, array $records): array { /* ... */ }
  public function addDNS(string $domain, array $record): array { /* ... */ }
  public function delDNS(string $domain, array $selector): array { /* ... */ }
  public function setNameServers(string $domain, array $nameservers): array { /* ... */ }
  public function raw(string $op, array $params=[]): array { /* ... */ }
}