PHP code example of dmamontov / geohelper-api-client-php

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

    

dmamontov / geohelper-api-client-php example snippets



$client = new \Geohelper\ApiClient(
    'api_key'
);


try {
    $response = $client->countriesList();
} catch (\Geohelper\Exception\CurlException $e) {
    echo "Connection error: " . $e->getMessage();
}

if ($response->isSuccessful()) {
    $countries = isset($response['result']) ? $response['result'] : array();
    foreach ($countries as $country) {
        echo $country['name'];
    }
} else {
    echo sprintf(
        "Error: [HTTP-code %s] %s",
        $response->getStatusCode(),
        $response->getErrorMsg()
    );
}
bash
composer