Skip to content

PHP extension(package) to work with Domain Connect (an open standard that makes it easy for a user to configure DNS)

License

Notifications You must be signed in to change notification settings

gaalferov/ext-domain-connect

Repository files navigation

PHP extension for Domain Connect

GitHub Actions GitHub Actions Codacy Badge

PHP version support Latest Version on Packagist Total Downloads

PHP client library for Domain Connect protocol. For details of the protocol, please visit: https://domainconnect.org Library offers Service Provider functionality in Sync mode.

Specification reference

https://github.com/Domain-Connect/spec/blob/master/Domain%20Connect%20Spec%20Draft.adoc

DC Templates

https://github.com/Domain-Connect/Templates/tree/master

Install

composer require gaalferov/php-ext-domain-connect

Usage

Sync flow

Just get the link. Discovery and template query part is solved automatically.

<?php

require 'vendor/autoload.php';

use DomainConnect\Exception\DomainConnectException;
use DomainConnect\Services\TemplateService;

try {
    $applyUrl = (new TemplateService())->getTemplateSyncUrl(
        'domainconnect.org', // domain name
        'exampleservice.domainconnect.org',  // providerId from the template
        'template1', // serviceId from the template
        [
            'IP' => '132.148.25.185',
            'RANDOMTEXT' => 'shm:1531371203:Hello world sync',
            'redirect_uri' => 'https://your-client-page.com',
            'state' => 'someState'
        ],
    );

    print_r($applyUrl);
} catch (DomainConnectException $e) {
    echo (sprintf('An error has occurred: %s', $e->getMessage()));
}

Output:

https://dcc.godaddy.com/manage/v2/domainTemplates/providers/exampleservice.domainconnect.org/services/template1/apply?domain=domainconnect.org&IP=132.148.25.185&RANDOMTEXT=shm%3A1531371203%3AHello+world+sync&redirect_uri=https%3A%2F%2Fyour-client-page.com&state=someState

Sync flow with signed request

<?php

require 'vendor/autoload.php';

use DomainConnect\Exception\DomainConnectException;
use DomainConnect\Services\TemplateService;

try {
    $templateService = new TemplateService();
    $privateKey = "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEA18SgvpmeasN4BHkkv0SBjAzIc4grYLjiAXRtNiBUiGUDMeTzQrKTsWvy9NuxU1dIHCZy9o1CrKNg5EzLIZLNyMfI6qiXnM+HMd4byp97zs/3D39Q8iR5poubQcRaGozWx8yQp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pTpsC5z0CVr7NQKBgQCsBTzpSQ9SVNtBpvzei8Hj1YKhkwTRpG8OSUYXgcbZp4cyIsZY0jBBmA3H19rSwhjsm9icjAGs5hfcD+AJ5nczEz37/tBBSQw8xsKXTrCQRUWikyktMKWqT1cNE3MQmOBMHDxtak2t6KDaR6RMDYE0m/L3JMkf3DSaUk323JIcQQKBgD6lHhw79Cenpezzf0566uWE1QF6Sv3kWk6Gkzo2jUGmjo2tG1v2Nj82DvcTuqvfUKSr2wTKINxnKGyYXGto0BykdxeFbR04cNcBB46zUjasro2ZCvIoAHCpohNBI2dL6dI+RI3jC/KY3jPNI0toaOTWkeAvJ7w09G2ttlv8qLNV\n-----END RSA PRIVATE KEY-----";
    $keyId = '_dck1';
    
    $applyUrl = $templateService->getTemplateSyncUrl(
        'domainconnect.org', // domain name
        'exampleservice.domainconnect.org',  // providerId from the template
        'template1', // serviceId from the template
        [
            'IP' => '132.148.25.185',
            'RANDOMTEXT' => 'shm:1531371203:Hello world sync',
            'redirect_uri' => 'https://your-client-page.com',
            'state' => 'someState'
        ],
        $privateKey,
        $keyId
    );

    print_r($applyUrl);
} catch (DomainConnectException $e) {
    echo (sprintf('An error has occurred: %s', $e->getMessage()));
}

Output:

https://domainconnect.1and1.com/sync/v2/domainTemplates/providers/exampleservice.domainconnect.org/services/template1/apply?domain=connect.domains&host=foo&IP=132.148.25.185&RANDOMTEXT=shm%3A1531371203%3AHello+world+sync&redirect_uri=http%3A%2F%2Fexample.com&state=someState&sig=HOoCBTFNIjWK3Qjy7CtWLB9HOcVvaGYFD3XsaI%2BZm%2BHtm%2FgsK66kfEfbi7Y8uoNOAbJXx3xfnbKrdASNa%2FPjQQKLk11NV%2BLNf3iDwkg7cOV9l54L2PqHFymOgu%2BiXr3I5aUkmA%2F19YAqiz3VJrh3K1XGeqc100cyZo%2BWq90bVcyWGVhIf5vYZEsU%2FzprckhmQdipqFfAB6XB4i72RzdxCKpBUFsyWcWYX80cz873pLN42uV%2BwGFUhSQ0qDC8d60n5m1f8h9Fdmik6%2FD%2BnmPpfK4Ge%2BHGnnq%2FpvR3nb95x9DKDHOd%2BfaIVcLhIZEbbVxIa57bGH%2FRUQiMbApBqkM4YQ%3D%3D&key=_dck1

Request Options (guzzle)

<?php

require 'vendor/autoload.php';

use DomainConnect\Exception\DomainConnectException;
use DomainConnect\Services\TemplateService;

try {
    $templateService = new TemplateService([
        'proxy' => [
            'http'  => 'tcp://localhost:8125',
            'https' => 'tcp://localhost:9124',
            'no' => ['.mit.edu', 'foo.com']
        ]
    ]);
    
    $applyUrl = $templateService->getTemplateSyncUrl(
        'domainconnect.org',
        'exampleservice.domainconnect.org',
        'template1',
        [
            'IP' => '132.148.25.185',
            'RANDOMTEXT' => 'shm:1531371203:Hello world sync',
            'redirect_uri' => 'http://example.com',
            'state' => 'someState'
        ],
    );

    print_r($applyUrl);
} catch (DomainConnectException $e) {
    echo (sprintf('An error has occurred: %s', $e->getMessage()));
}

Tests

To run tests use next command: composer tests or php vendor/bin/phpunit ./tests

About

PHP extension(package) to work with Domain Connect (an open standard that makes it easy for a user to configure DNS)

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages