PHP code example of mrkriskrisu / netcup-api

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

    

mrkriskrisu / netcup-api example snippets


$api = new \Netcup\API("apiKey", "apiPassword", "123456");
echo "Login " . ($api->isLoggedIn() ? 'successful! :)' : 'not successful! :c') . PHP_EOL;

$domain = $api->infoDomain('k118.de');
print_r($domain->getDnsRecords());

$domain = $api->infoDomain('k118.de');
$domain->createNewDnsRecord(new DnsRecord(
    hostname: 'www', 
    type: 'A', 
    destination: '127.0.0.1'
));

$domain = $api->infoDomain('k118.de');
$record = $domain->getDnsRecords()[0];
$record->update(destination: '127.0.0.2');

$domain = $api->infoDomain('k118.de');
$record = $domain->getDnsRecords()[0];
$record->delete();

$handle = $api->createHandle(
    name: 'Edward Keir',
    street: 'Street of God 1',
    postalCode: '12345',
    city: 'Examplecity',
    countryCode: 'DE',
    telephone: '+49.123456789',
    email: '[email protected]'
);

$handle->setCity('Kassel'); //this will directly edit the data at the netcup database as well

$logoutResult = $api->logout();