PHP code example of lyhiving / dnspod_api

1. Go to this page and download the library: Download lyhiving/dnspod_api 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/ */

    

lyhiving / dnspod_api example snippets


     use dnspod_api\Dnspod;
    $uid = 12345;
    $token = X12345;
    $DP = new Dnspod($uid, $token);

    $domain = 'example.com';
    $value = array(
        '255.255.255.1',
        '255.255.255.2',
        '255.255.255.3',
        );
    $name = 'www';
    $type = 'A';
    $DP->Records($domain, $value, $name, $type, true);

    $domain = 'example.com';
    $DP->copyArecord($domain);

    $copyDomain = 'google.com';
    $toDomain = 'example.com';
    echo $DP->getDomainInfo($copyDomain, $toDomain);

    $domain = 'example.com';
    echo $DP->getRecordList($domain);

    $job_id = 'j12345';
    echo $DP->getBatchDetail($job_id);

    $domain = 'example.com';
    $name = 'www';
    $value = '255.255.255.0';
    $type = 'A';
    echo $DP->addRecord($domain, $name, $value, $type);

    $domain_id = '12345';
    $record[0] = array('name'=>'WWW', 'type'=>'A', 'value'='255.255.255.0', 'mx'=>1);
    echo $DP->batchAddRecord($domain_id, $record);

    $domain = 'example.com';
    $record_id = 'E12345';
    $name = 'WWW2';
    $value = '255.255.255.0';
    $type = 'A';
    $mx = 1;
    echo $DP->recordModify($domain, $record_id, $name, $value, $type, $mx);

    $domain = 'example.com';
    $record_id = 'E12345';
    echo $DP->recordRemove($domain, $record_id);

    //Get the API version number
    echo $DP->getVersion();
    
    //Get the level allowed line
    $domain = 'example.com';
    echo $DP->getRecordLine($domain);

    //Change API Region to Global Network And
    $DP->setRegion('global');

    //Change API Region to China Network
    $DP->setRegion('cn');
    
    //Get a list of domain names
    echo $DP->getDomainList();
    
    //Construct a new record table
    $name = 'example.com';
    $type = 'A';
    $value = '255.255.255.0';
    $DP->newRecords($name, $type, $value);

    //Remove share record
    $domain = 'example.com';
    $share_email = '[email protected]';
    echo $DP->shareRemove($domain, $share_email);