How to Validate Domain Quality in PHP

Cloudmersive
1 min readMar 25, 2024

--

Using a few lines of PHP code, we can easily investigate the quality of a domain name to ensure its trustworthiness.

We’ll call a free API that scores an input domain name from 0.0 (lowest quality) to 10.0 (highest quality).

To begin, let’s first install the PHP client using Composer by executing the following command from the command line:

composer require cloudmersive/cloudmersive_validate_api_client

Next, let’s turn our attention to authorization. We’ll need a free API key to make up to 800 API calls per month (with no commitments).

Lastly, let’s call the function using the below PHP code examples, and let’s make sure to enclose our input domain name string in quotes (e.g., “cloudmersive.com”):

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');



$apiInstance = new Swagger\Client\Api\DomainApi(


new GuzzleHttp\Client(),
$config
);
$domain = "domain_example"; // string | Domain name to check, for example \"cloudmersive.com\".

try {
$result = $apiInstance->domainQualityScore($domain);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DomainApi->domainQualityScore: ', $e->getMessage(), PHP_EOL;
}
?>

Now we can easily check the quality of a domain name using a service with access to 9+ million domains.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Responses (2)