PHP code example of emild / api3-lib

1. Go to this page and download the library: Download emild/api3-lib library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

emild / api3-lib example snippets


use NameISP\API3\Client;

$api = new Client('YOUR_API_KEY');

$api = new Client('YOUR_API_KEY', 'https://example.com/api');

use NameISP\API3\Exception\BaseException;

try {
    $api->searchDomain('example.org');
} catch (BaseException $e) {
    // Do something...
}

use NameISP\API3\Exception\ApiException;

try {
    $api->searchDomain('example.org');
} catch (ApiException $e) {
    var_dump($e->getCode()); // int(2303)
    var_dump($e->getMessage()); // string(21) "Object does not exist"
}

/**
 * @param string $domainName must be fully qualified domain name
 * @param int $itemYear
 * @param int $ownerId
 * @param int $adminId
 * @param int $techId
 * @param bool $autoRenew
 * @param bool $shieldWhoIs
 * @param bool $trustee
 * @param bool $tmchacceptance is only 

/**
 * @param string $domainName must be fully qualified domain name
 * @param string $auth
 */
public function createDomainTransfer($domainName, $auth = false)

/**
 * @param int $itemid
 */
public function domainDetails($itemid)

/**
 * @param string $domainName
 */
public function domainGenAuthCode($domainName)

/**
 * @param string $domainName
 * @param int $limit default: 100, min: 1 max: 1000, invalid values are ignored and default value is used
 * @param int $start default: 0
 */
public function domainList($domainName = null, $limit = null, $start = null)

/**
 * @param array|string $domainName must be fully qualified domain name
 * @param bool $setAutoRenew
 * @param bool $setShieldWhoIs
 * @param array $addLabel
 * @param array $removeLabel
 */
public function editDomain($domainName, $setAutoRenew = null, $setShieldWhoIs = null, array $addLabel = null, array $removeLabel = null)

$api->editDomain('example.com', false, null, ['label']); // Returns an empty array on success

/**
 * @param array|string $domainName
 */
public function searchDomain($domainName)

/**
 * @param string $domainName must be fully qualified domain name
 * @param array $nameServer
 */
public function updateDomainDNS($domainName, array $nameServer)

/**
 * @param string $domainName must be fully qualified domain name
 * @param int $itemYear
 */
public function updateDomainRenew($domainName, $itemYear)

/**
 * @param string $domainName
 * @param string $nameServer
 */
public function checkDnsZone($domainName, $nameServer)

$api->checkDnsZone('example.com', 'ns1.nameisp.info'); // Returns true or false

/**
 * DnsAddRecord
 *
 * Notes:
 * Using $type = redirect will create a redirect
 *  - Valid values for $redirectType are 301, 302 & frame. Default: 301
 *  - Forward url is to be entered in content ex. http://www.example.com
 * Using $type = mailforward will create a mailforward
 *  - Valid values for name is full qualified email address for the domainname
 *  - Forward email is to be entered in content ex. [email protected]
 *
 * @param string $domainName
 * @param string $name
 * @param string $type
 * @param string $content
 * @param int $ttl
 * @param int $prio
 * @param string $redirectType
 */
public function dnsAddRecord($domainName, $name, $type, $content, $ttl, $prio = null, $redirectType = null)

/**
 * @param int $recordId
 * @param string $domainName
 */
public function dnsDeleteRecord($recordId, $domainName)

$api->dnsDeleteRecord(16992196,  'example.com'); // Returns an empty array on success

/**
 * @param string $domainName
 */
public function dnsGetRecords($domainName)

/**
 * DnsUpdateRecord
 *
 * Notes:
 * Using type = redirect will create a redirect
 *  - Valid values for redirecttype are 301, 302 & frame. Default: 301
 *  - Forward url is to be entered in content ex. http://www.example.com
 *
 * @param int $recordId
 * @param string $domainName
 * @param string $name
 * @param string $type
 * @param string $content
 * @param int $ttl
 * @param int $prio
 * @param string $redirectType
 */
public function dnsUpdateRecord($recordId, $domainName, $name, $type, $content, $ttl, $prio = null, $redirectType = null)

$api->dnsUpdateRecord(16992196, 'example.com', '*.example.com', 'A', '1.1.1.2', 3600); // Returns an empty array on success

/**
 * PublishDnsSec
 *
 * Notes:
 * $flags
 *  - 256 ZSK
 *  - 257 KSK
 * $alg can at the time of writing use one of the following integers:
 *  - 5 RSA/SHA-1
 *  - 7 RSASHA1-NSEC3-SHA1
 *  - 8 RSA/SHA-256
 *  - 10 RSA/SHA-512
 *  - 12 GOST R 34.10-2001
 *  - 13 ECDSA/SHA-256
 *  - 14 ECDSA/SHA-384
 *
 * @param string $domainName
 * @param string $dnsKey
 * @param int $flags
 * @param int $alg
 */
public function publishDnsSec($domainName, $dnsKey, $flags, $alg)

$api->publishDnsSec('example.com', 'c6884357e49fd6b1fdede867c96aafb1', 256, 5); // Returns an empty array on success

/**
 * @param string $domainName
 */
public function unpublishDnsSec($domainName)

$api->unPublishDnsSec('example.com'); // Returns an empty array on success

/**
 * PriceList
 *
 * Note:
 * Using $print will ignore $limit and $start parameters, WARNING using $print = true will result with a large JSON object, it’s recommended to use $print = true together with $skipRules = true to limit the JSON size.
 *
 * @param bool $print
 * @param bool $skipRules
 * @param string $tldName
 * @param int $priceTypes
 * @param int $limit
 * @param int $start
 */
public function priceList($print = null, $skipRules = null, $tldName = null, $priceTypes = null, $limit = null, $start = null)

/**
 * @param string $label
 * @param integer $starred
 */
public function createLabel($label, $starred = null)

/**
 * @param int $labelId
 */
public function deleteLabel($labelId)

$api->deleteLabel(2317); // Returns an empty array on success

public function getLabels()

/**
 * UpdateLabel
 *
 * Note:
 * Valid parameter values are: name, starred
 *
 * @param int $labelId
 * @param string $parameter
 * @param string $value
 */
public function updateLabel($labelId, $parameter, $value)

$api->updateLabel(2317, 'name', 'updated label 1'); // Returns an empty array on success

/**
 * RequestCancellation
 *
 * Note:
 * Only statuses with cancelable flag are cancelable.
 *
 * @param int $reqId
 */
public function requestCancellation($reqId)

/**
 * @param int $reqId
 */
public function requestDetails($reqId)

/**
 * @param string $domainName
 * @param string $reqType
 * @param int $limit default: 100, min: 1 max: 1000, invalid values are ignored and default value is used
 * @param int $start default: 0
 */
public function requestList($domainName = null, $reqType = null, $limit = null, $start = null)

/**
 * @param int $reqId
 * @param string $error parameter from error list
 */
public function requestUpdate($reqId, $error)

/**
 * ContactList
 *
 * Note:
 * Valid $filters keys:
 * firstname, lastname, organization, orgnr, address1, zipcode, city, countrycode, phone, fax, email
 *
 * @param array $filters key-value array with filters
 * @param int $limit default: 100, min: 1 max: 1000, invalid values are ignored and default value is used
 * @param int $start default: 0
 * @param string $searchString is a free text search parameter, use this parameter to search every field. If this parameter is used all other parameters are ignored
 */
public function contactList(array $filters = [], $searchString = null, $limit = null, $start = null)

/**
 * @param string $firstName
 * @param string $lastName
 * @param string $email
 * @param string $orgnr
 * @param string $address1
 * @param string $zipCode
 * @param string $city
 * @param string $countryCode
 * @param string $phone
 * @param string $organization
 * @param string $fax
 */
public function createContact($firstName, $lastName, $email, $orgnr, $address1, $zipCode, $city, $countryCode, $phone, $organization = null, $fax = null)

/**
 * UpdateContact
 *
 * Notes:
 * Private persons can’t update $firstName or $lastName
 * Organization can’t update $organization
 * No one can update orgnr
 * if value does not exist, value is added else it is updated
 *
 * Possible $fields keys:
 * firstname, lastname, organization, address1, zipcode, city, countrycode, phone, fax, email
 *
 * @param int $contactId
 * @param array $fields
 */
public function updateContact($contactId, array $fields)

$api->updateContact(1234181, [
    'city' => 'New York',
    'countrycode' => 'us'
]); // Returns an empty array on success