Geocoder
Geocoder copied to clipboard
Add premium endpoint and token authentication support for Geonames provider
Summary
This PR adds support for Geonames premium accounts by introducing optional token and secure parameters to the Geonames provider.
Changes
- Added optional
$tokenparameter to the Geonames constructor for premium account authentication - Added
$secureboolean flag to enable the secure HTTPS endpoint (https://secure.geonames.net) - Implemented dynamic base URL selection based on the
$secureflag - 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 tonull) -
secure: Use secure endpoint (optional, defaults tofalse)