PHP code example of api-check / php-client

1. Go to this page and download the library: Download api-check/php-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-client example snippets


use ApiCheck\Api\ApiClient;

ient();
$apicheckClient->setApiKey("YOUR_API_KEY");

$address = $apicheckClient->lookup('nl', ['postalcode' => '2513AA', 'number' => 1]);
// Do something with the result:
print("🥳 Yay! We have a result: \n $address->street $address->number \n $address->postalcode $address->city \n {$address->Country->name}");

$results = $apicheckClient->search('be', 'city', ['name' => 'Namur']);

use ApiCheck\Api\ApiClient;
use ApiCheck\Api\Exceptions\NotFoundException;
use ApiCheck\Api\Exceptions\ValidationException;
use ApiCheck\Api\Exceptions\UnsupportedCountryException;

try {
    $address = $apicheckClient->lookup('nl', ['postalcode' => '2513AA', 'number' => 1]);
} catch (NotFoundException $e) {
    // No results have been found using the supplied data
} catch (ValidationException $e) {
    // One of the submitted fields is not valid or set
} catch (UnsupportedCountryException $e) {
    // The given country-code is not supported
}
bash
$ composer