PHP code example of spikkl / spikkl-php-client

1. Go to this page and download the library: Download spikkl/spikkl-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/ */

    

spikkl / spikkl-php-client example snippets


$spikkl = new \Spikkl\Api\ApiClient();
$spikkl->setApiKey("API_KEY");

$results = $spikkl->lookup("NLD", "2611HB", "175");

$results = $spikkl->reverse("NLD", 4.899431, 52.379189);

try {
    $results = $spikkl->lookup("NLD", "2611HB", "175");
} catch (\Spikkl\Api\Exceptions\AccessRestrictedException $exception) {
    // The API key is restricted for designated origins
} catch (\Spikkl\Api\Exceptions\InvalidApiKeyException $exception) {
    // The authentication with the Spikkl API failed
} catch (\Spikkl\Api\Exceptions\RevokedApiKeyException $exception) {
    // The provided API key is restricted.
} catch (\Spikkl\Api\Exceptions\ZeroResultsException $exception) {
    // The API call is successful but the API cannot find any results
} catch (\Spikkl\Api\Exceptions\QuotaReachedException $exception) {
    // The quota is reached for your current plan.
} catch (\Spikkl\Api\Exceptions\InvalidRequestException $exception) {
    // One of the query parameters (postal_code, street_number, or street_number_suffix)
    // might be invalid or missing
}

try {
    $results = $spikkl->reverse("NLD", 4.899431, 52.379189);
} catch (\Spikkl\Api\Exceptions\OutOfRangeException $exception) {
    // The coordinates provided do not correspond with the country code
} 
bash
$ composer