How can PHP be used to automatically register subdomains on Domainfactory?

To automatically register subdomains on Domainfactory using PHP, you can utilize the DomainFactory API to programmatically create subdomains. This involves sending HTTP requests to the DomainFactory API endpoints with the necessary parameters to register the subdomain.

<?php

$apiKey = 'YOUR_API_KEY';
$domain = 'example.com';
$subdomain = 'subdomain';

$url = 'https://api.domainfactory.de/v1/domains/' . $domain . '/subdomains/' . $subdomain;

$data = [
    'type' => 'A',
    'ip' => '127.0.0.1'
];

$options = [
    'http' => [
        'header' => "Content-type: application/json\r\n" .
                    "Authorization: Bearer " . $apiKey,
        'method' => 'POST',
        'content' => json_encode($data)
    ]
];

$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);

if ($result === false) {
    echo "Failed to register subdomain";
} else {
    echo "Subdomain registered successfully";
}

?>