PHP code example of stitch-digital / nametodomain-php-sdk
1. Go to this page and download the library: Download stitch-digital/nametodomain-php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stitch-digital / nametodomain-php-sdk example snippets
use NameToDomain\PhpSdk\NameToDomain;
// Single resolution (sync)
$result = NameToDomain::make($token)->resolve(
company: 'Stitch Digital',
country: 'GB'
);
// Batch enrichment (async)
$job = NameToDomain::make($token)->enrichBatch(
items: [
['company' => 'Stripe', 'country' => 'US'],
['company' => 'Spotify', 'country' => 'SE'],
]
);
// Check batch job status and get results
$batchResult = NameToDomain::make($token)->enrichBatchJob(jobId: $job->id);
// Or iterate over all batch items (paginated)
$items = NameToDomain::make($token)->enrichBatchJobItems(jobId: $job->id)->collect()->all();
use NameToDomain\PhpSdk\NameToDomain;
$client = NameToDomain::make('your-api-token');
$client = new \NameToDomain\PhpSdk\NameToDomain(
'your-api-token',
'https://nametodomain.dev/api/v1',
30
);
try {
$client->resolve(company: '', country: 'US');
} catch (\NameToDomain\PhpSdk\Exceptions\ValidationException $exception) {
$exception->getMessage(); // returns a string describing the errors
$exception->getErrors(); // returns an array with all validation errors
$exception->getErrorsForField('company'); // get errors for a specific field
}
try {
$client->enrichJob(jobId: 'invalid-id');
} catch (\NameToDomain\PhpSdk\Exceptions\NameToDomainException $exception) {
$exception->getMessage();
$exception->response; // access the Saloon Response object for debugging
}
$job = NameToDomain::make($token)->enrich(
company: 'Stripe',
country: 'US',
emails: ['[email protected]'],
identifier: 'stripe-001'
);
// Poll for result
$result = NameToDomain::make($token)->enrichJob($job->id);
// When completed, $result->output is a JobItem with the enriched data
use NameToDomain\PhpSdk\NameToDomain;
use NameToDomain\PhpSdk\Requests\Resolve\ResolveRequest;
$client = NameToDomain::make('your-api-token');
$request = new ResolveRequest('Stripe', 'US');
$response = $client->send($request)->dto();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.