MrKrisKrisu / netcup-api

PHP Library to communicate to the netcup GmbH CCP and DNS API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP Library for netcup Domain API

Codacy Badge

This library is not related to the netcup GmbH, it is provided by a third party.

⚠️ Warning: This library is currently still WIP! Please use it only if you agree that the following releases contain breaking changes.

Installation

You can simply install this library using Composer by running composer require mrkriskrisu/netcup-api. You'll need PHP8.

Examples

Login to the API

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

Domains

Get domains and DNS-Records

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

Create new DNS-Record

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

Update existing DNS-Record

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

Delete DNS-Record

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

Domain-Handles (Reseller only)

Create and update Handle

$handle = $api->createHandle(
    name: 'Edward Keir',
    street: 'Street of God 1',
    postalCode: '12345',
    city: 'Examplecity',
    countryCode: 'DE',
    telephone: '+49.123456789',
    email: 'example@k118.de'
);

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

Logout

You can end the created session. This is optional. If you don't, the token will automatically expire after 15 minutes.

$logoutResult = $api->logout();

Official links

About

PHP Library to communicate to the netcup GmbH CCP and DNS API

License:MIT License


Languages

Language:PHP 100.0%