有没有办法使用Google的API来检索用户的当前邮政编码而无需明确要求他们获得许可? 我了解Google现在使用OAuth 2.0,这是一种身份验证协议,用户必须允许特定服务的权限。 但是,我想找到一个用户的位置,而不必问他们!
这可能吗? 我对翻译IP地址不感兴趣,因为它们通常会返回错误的结果。 同样,HTML5的地理位置功能也不起作用,因为它也需要用户权限。
Is there any way to use Google's API to retrieve a user's current zipcode without explicitly asking them for permission? I understand Google now uses OAuth 2.0 which is an authentication protocol where a user must allow permission to a particular service. However, I would like to find a user's location without having to ask them!
Is this possible? I'm not interested in translating IP addresses as they typically return incorrect results. Likewise, HTML5's geolocation feature would not work as it too requires user permission.
最满意答案
你一定要oAuth用户使用谷歌(或Facebook ......或[在此处插入社交网络])以获取有关存储在第三方的用户的任何信息(如家庭或工作“邮政编码”)现场。 但是一旦通过身份验证,您就无法获得用户当前的邮政编码或位置。 您想要他们当前的位置或他们的家庭住址或工作地址 - 您可能想澄清一下。 无论如何,如果你想要用户的当前位置,我建议使用HTML5地理定位API。
地理定位API的最简单用法如下所示:
function get_location() { navigator.geolocation.getCurrentPosition(show_map); }没有检测,没有错误处理,也没有选项。 您的Web应用程序应该至少包含前两个。 要检测对地理位置API的支持,您可以使用Modernizr :
function get_location() { if (Modernizr.geolocation) { navigator.geolocation.getCurrentPosition(show_map); } else { // no native support; maybe try Gears? } }HTML5地理定位的资源:
http://diveintohtml5.info/geolocation.html http://html5doctor.com/finding-your-position-with-geolocation/ HTML5 Geolocation API的W3规范: http : //dev.w3.org/geo/api/spec-source.htmlYou will definitely have to oAuth a user using Google (or Facebook ... or [insert social network here]) in order to gain access to any information (such as home or work "zipcode") about that user stored on a 3rd party site. But once authenticated, you wouldn't get a user's current zipcode or location. Do you want their current location or their home address or their work address - you may want to clarify. Anyways, if you want a user's current location I would suggest using the HTML5 geolocation API.
The simplest use of the geolocation API looks like this:
function get_location() { navigator.geolocation.getCurrentPosition(show_map); }That has no detection, no error handling, and no options. Your web application should probably include at least the first two of those. To detect support for the geolocation API, you can use Modernizr:
function get_location() { if (Modernizr.geolocation) { navigator.geolocation.getCurrentPosition(show_map); } else { // no native support; maybe try Gears? } }Resources for HTML5 geolocation:
http://diveintohtml5.info/geolocation.html http://html5doctor.com/finding-your-position-with-geolocation/ W3 spec for HTML5 Geolocation API: http://dev.w3.org/geo/api/spec-source.html更多推荐
发布评论