PHP code example of aternus / geonames-client

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

    

aternus / geonames-client example snippets




use GeoNames\Client as GeoNamesClient;

$g = new GeoNamesClient('username');

// get a list of supported endpoints
$endpoints = $g->getSupportedEndpoints();

// get info for country
// note that I'm using the array destructor introduced in PHP 7.1
[$country] = $g->countryInfo([
    'country' => 'IL',
    'lang'    => 'ru', // display info in Russian
]);

// country name (in Russian)
$country_name = $country->countryName;

// spoken languages (ISO-639-1)
$country_languages = $country->languages;

$g = new GeoNamesClient('username', '', ['api_url' => 'https://custom-premium.geonames.org']);

$g = new GeoNamesClient('username');
$g->setOptions(['api_url' => 'https://custom-premium.geonames.org'])





use GeoNames\Client as GeoNamesClient;