PHP code example of alchemy / geonames-api-consumer

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

    

alchemy / geonames-api-consumer example snippets


$connector = ALchemy\Geonames\Connector::create($serverUrl);

// returns an array of Alchemy\Geonames\Geoname objects
$geonames = $connector->search('Paris');

// limit to 50 results
// use '89.73.4.152' as IP address for closeness sort
$connector->search('Paris', 50, '89.73.4.152');

// returns a Alchemy\Geonames\Geoname object
$geoname = $connector->ip('89.73.4.152');

// returns a Alchemy\Geonames\Geoname object
$geoname = $connector->geoname(2988507);

$app = new Silex\Application();
$app->register(new Alchemy\Geonames\GeonamesServiceProvider(), array(
    'geonames.server-uri' => 'http://geonames.domain.tld',  // mandatory parameter
));