PHP code example of api-check / php-laravel-client
1. Go to this page and download the library: Download api-check/php-laravel-client 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/ */
api-check / php-laravel-client example snippets
use ApiCheck\Laravel\Facades\ApiCheck;
// Lookup an address (NL, LU)
$address = ApiCheck::lookup('nl', [
'postalcode' => '2513AA',
'number' => 1,
]);
// Get available number additions
$additions = ApiCheck::getNumberAdditions('nl', '2513AA', 1);
// Search for addresses (18 European countries)
$results = ApiCheck::search('be', 'city', ['name' => 'Brussels']);
// Global search
$results = ApiCheck::globalSearch('nl', 'amsterdam', ['limit' => 10]);
// Verify email
$emailResult = ApiCheck::verifyEmail('[email protected]');
// Returns: disposable_email (bool), greylisted (bool), status ("valid"|"invalid"|"unknown")
// Verify phone
$phoneResult = ApiCheck::verifyPhone('+31612345678');
// Returns: valid (bool), country_code, area_code, international_formatted, etc.
use ApiCheck\Api\ApiClient;
public function __construct(ApiClient $apiCheck)
{
$this->apiCheck = $apiCheck;
}
public function index()
{
$address = $this->apiCheck->lookup('nl', ['postalcode' => '2513AA', 'number' => 1]);
}
use ApiCheck\Api\Exceptions\NotFoundException;
use ApiCheck\Api\Exceptions\ValidationException;
use ApiCheck\Api\Exceptions\UnsupportedCountryException;
use ApiCheck\Api\Exceptions\ApiException;
try {
$address = ApiCheck::lookup('nl', ['postalcode' => '2513AA', 'number' => 1]);
} catch (NotFoundException $e) {
// No results found
} catch (ValidationException $e) {
// Invalid input
} catch (UnsupportedCountryException $e) {
// Country not supported for this endpoint
} catch (ApiException $e) {
// General API error
}