mrkriskrisu/netcup-api

Library to communicate to the netcup CCP and DNS API

v0.0.6 2024-05-09 12:16 UTC

This package is auto-updated.

Last update: 2024-05-09 12:17:33 UTC


README

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