英文:
How to find the time it will take to travel between two places in an android app
问题
我正在进行学校项目,并且需要在安卓应用程序中计算两地之间的旅行时间,最好能够指定交通工具的选项。
我发现了Google Distance Matrix API(文档在此),它似乎具有我正在寻找的功能,但它警告...
> “如果您正在构建移动应用程序,您需要引入代理服务器,以充当您的移动应用程序与Google地图API Web服务之间的中间人。”
我知道这是为了保护API密钥,我想要严格遵循这个。我想知道,是否有另一种方法可以在不设置代理服务器的情况下获得我需要的应用程序数据?
我知道我可以使用像Heroku这样的服务来运行访问API的代码,但考虑到这只是一个学校项目,这似乎是一个困难的选项。还有其他想法可以获得我应用程序的旅行时间吗?
英文:
I am working on a school project and need to calculate the time it will take to travel between two locations preferably with the option to specify the mode of transportation inside of an android app.
I have come across the Google Distance Matrix API (documentation here) which seems to have the features that I am looking for, but it warns...
> "If you are building a mobile application, you will need to introduce a proxy server to act as intermediary between your mobile application and the Google Maps API Web Services."
I know that this is for the protection of the API key and want to follow this pretty diligently. I'm wonder, is there another way to get the data I need for the app without setting up a proxy server?
I know I could use a service like Heroku to run the code that accesses the API, but this seems like a difficult option given that this is just a school project. Any other ideas on how to get the travel time for my app?
答案1
得分: 1
设置代理服务器是保护您的 API 密钥的最佳方法,但 Google 也建议使用其他安全技术,如混淆和固定。
话虽如此,如果这是一个学校项目,并且您不会在生产环境中公开您的 API 密钥,那么您可以将您的 API 密钥保持未受限制(无需代理服务器)。
但请确保您定期监控您的 API 使用情况,并根据需要定期或需要时重新生成您的 API 密钥。强烈建议您根据此常见问题解答设置每日配额限制和预算警报,以确保不超出预算。
希望能对您有所帮助!
英文:
Setting up a proxy server is the best way to secure your API key, but Google also suggests other security techniques such as obfuscation and pinning.
Having said that, if this is a school project and you won't make your API key public in a production environment, then you can just leave your API key unrestricted (and without a proxy server).
But do make sure that you monitor your API usage on a regular basis and that you regenerate your API key periodically and/or as needed. It's also strongly recommended that you set daily quota limits and budget alerts as per this FAQ so that you don't go over budget regardless.
Hope this helps!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论