-
Couldn't load subscription status.
- Fork 523
Add premium endpoint and token authentication support for Geonames provider #1261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add premium endpoint and token authentication support for Geonames provider #1261
Conversation
…ovider - Add optional token parameter to Geonames constructor - Add secure flag to enable https://secure.geonames.net endpoint - Support dynamic base URL (api.geonames.org or secure.geonames.net) - Append token parameter to all API requests when provided - Maintain backward compatibility with existing username-only authentication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your PR.
On top of the following comments, here are a few extra remarks:
- Is
secure.geonames.orgonly available if you provide a token?
Your PR description seems to say so but the code doesn't reflect that. - Please add some tests for the use of
$tokenand$secure.
You'll have to updatephpunit.xml.distand temporarily set your token (do not commit it), the response using your token will be cached in.cached_responsesso we can keep testing it without needing your token.
Thanks.
src/Provider/Geonames/Geonames.php
Outdated
| // Determine base URL based on secure flag | ||
| if ($secure) { | ||
| $this->baseUrl = 'https://secure.geonames.net'; | ||
| } else { | ||
| $this->baseUrl = 'http://api.geonames.org'; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the use of constants. You seem to have made the existing constants irrelevant.
src/Provider/Geonames/Geonames.php
Outdated
| $this->token = $token; | ||
|
|
||
| // Determine base URL based on secure flag | ||
| if ($secure) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use strict comparison.
| if ($secure) { | |
| if ($secure === true) { |
Summary
This PR adds support for Geonames premium accounts by introducing optional
tokenandsecureparameters to the Geonames provider.Changes
$tokenparameter to the Geonames constructor for premium account authentication$secureboolean flag to enable the secure HTTPS endpoint (https://secure.geonames.net)$secureflagappendToken()method to append the token parameter to API requests when providedBenefits
Testing
Documentation
Premium accounts can now be used as follows:
username: Your Geonames usernametoken: Your premium account token (optional, defaults tonull)secure: Use secure endpoint (optional, defaults tofalse)