mijnpartnergroep-nl/sidn-suggestion-api-php

PHP版本的SIDN建议API客户端库。SIDN是.nl域名注册商。

v0.1 2021-10-13 08:47 UTC

This package is auto-updated.

Last update: 2024-09-26 15:44:53 UTC


README

SIDN建议API的PHP客户端

要求和授权

要使用API,您必须通过向 support@sidn.nl 发送请求或联系您的SIDN代表来请求访问权限。批准后,您将获得访问API的权限。API使用客户端授权流程进行服务器端授权。要开始授权流程,您需要请求clientId和clientSecret。您可以从SIDN支持处请求这些。

安装

安装此客户端的最简单方法是使用Composer来要求它。

使用 composer require MijnPartnerGroep-nl/sidn-suggestion-api-php:^0.1 安装

或者将其添加到您的composer.json中

{ 
    "require": {
        "MijnPartnerGroep-nl/sidn-suggestion-api-php": "^0.1"
    }
}

示例用法

示例用法,如示例文件夹中所示。

<?php
include("vendor\autoload.php");

use \Sidn\Suggestion\Api\Exceptions\ApiException;
use  \Sidn\Suggestion\Api\SidnSuggestionApiClient;

try {
    // Create new instance of SidnSuggestionApiClient
    $sidnApi = new SidnSuggestionApiClient();

    // Authenticate using Client Id and Client Secret provided by SIDN
    $auth = $sidnApi->authenticate->authenticate($client_id, $client_secret);
    $sidnApi->setAccessToken($auth->access_token);

    // Search for domain suggestions
    $suggestions = $sidnApi->suggestion->search("bike.nl", 1000);
    print_r($suggestions->suggestions);

    // Optionally, query the used configuration from the results
    print_r($suggestions->config);

    // Optionally, query the used domain (cleaned) from the results
    print_r($suggestions->original);
} catch (ApiException $ae) {
    echo "Error occured at: ".$ae->getTimestamp() . ";<br />Message: ".$ae->getMessage();
    throw $ae;
}