PHP code example of stereoflo / ispmanager-php-api

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

    

stereoflo / ispmanager-php-api example snippets




$server = new \IspApi\Server\Server('server', 1500);
$credentials = new \IspApi\Credentials\Credentials('user', 'password');
$format = new \IspApi\Format\JsonFormat();
$client = new \IspApi\HttpClient\CurlClient(); // тут может быть любой ваш http клиент


$getDomainList = new \IspApi\Func\Dns\GetList();

$deleteDomain = new \IspApi\Func\Dns\Delete('domain.ru');

$addDomain = new \IspApi\Func\Domain\Add();
$addDomain->setAdditional([
    'name'    => 'domain.ru',
    'ip'      => '127.0.0.1',
    'ns'      => 'dns3.domain.net. dns1.domain.net. dns2.domain.net.',
    'ns_list' => '',
    'mx'      => 'mail',
    'mx_list' => '',
    'elid'    => '',
    'sok'     => 'ok',
]);

$listEntriesByDomain = new \IspApi\Func\Dns\Record\GetList('domain.ru');

$deleteDomainEntry = new \IspApi\Func\Dns\Record\Delete('test A  127.0.0.1', 'domain.ru');

$addItemToDomain = new \IspApi\Func\Dns\Record\Add('', 'domain.ru');
$addItemToDomain->setAdditional([
    'name' => 'test1',
    'sdtype' => 'A',
    'addr' => '127.0.0.1',
    'prio' => '',
    'wght' => '',
    'port' => '',
    'elid' => '',
    'sok'  => 'ok',
]);

$getSoaRecord = new \IspApi\Func\Dns\Soa\GetSoa('domain.ru');

$domainSoaEdit = new \IspApi\Func\Dns\Soa\Edit('domain.ru');
$domainSoaEdit->setAdditional([
    'primary' => 'dns3.domain.net.',
    'email'   => '[email protected]',
    'serial'  => '2018012514',
    'refresh' => '10800',
    'retry'   => '3600',
    'expire'  => '604800',
    'ttl'     => '3600',
    'sok'     => 'ok',
]);

$ispManager = new IspApi\IspManager();
$response = $ispManager->setServer($server)
    ->setCredentials($credentials)
    ->setFunc($getDomainList)
    ->setHttpClient($client)
    ->setFormat($format);

try {
    $result = $ispManager->setFunc($domainSoaEdit)->execute();
    //do something
} catch (\Exception $exception) {
    var_dump($exception);
    //do something
}
bash
composer