Geocoder icon indicating copy to clipboard operation
Geocoder copied to clipboard

Add premium endpoint and token authentication support for Geonames provider

Open AronNovak opened this issue 3 months ago • 2 comments

Summary

This PR adds support for Geonames premium accounts by introducing optional token and secure parameters to the Geonames provider.

Changes

  • Added optional $token parameter to the Geonames constructor for premium account authentication
  • Added $secure boolean flag to enable the secure HTTPS endpoint (https://secure.geonames.net)
  • Implemented dynamic base URL selection based on the $secure flag
  • Added appendToken() method to append the token parameter to API requests when provided
  • Updated all API endpoint calls to use the dynamic base URL and token parameter

Benefits

  • Enables use of Geonames premium accounts with token authentication
  • Supports the secure HTTPS endpoint for premium users
  • Maintains full backward compatibility with existing free accounts using username-only authentication
  • No breaking changes to existing code

Testing

  • Tested with premium Geonames account using token authentication and secure endpoint
  • Verified backward compatibility with username-only authentication

Documentation

Premium accounts can now be used as follows:

$provider = new Geonames($client, 'username', 'token', true);
  • username: Your Geonames username
  • token: Your premium account token (optional, defaults to null)
  • secure: Use secure endpoint (optional, defaults to false)

AronNovak avatar Oct 17 '25 11:10 AronNovak