像谷歌收件箱一样获取用户的家、工作和加星标的位置 [英] Get user's home, work and starred locations like Google Inbox does

查看:16
本文介绍了像谷歌收件箱一样获取用户的家、工作和加星标的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您在 Google Inbox 中暂停消息并选择选择地点"时,它会显示一个列表,其中包含您的家庭和工作地址(来自 Google Now)以及您的 Google 地图个人资料中的加星标位置.其他 Google 应用(例如 Keep)也提供类似的功能.

我想在我的应用程序中实现这一点,但找不到公开该信息的正确 API.这是 Google 不会向 3rd 方公开的内容吗(我想那里有滥用的余地)?

如果没有,如何实现?哪些 API 有数据?

解决方案

Google Now 利用对您的位置数据的分析(在您的 Google 帐户设置中启用的已登录 Google + 位置服务的任何和所有设备上)来确定您的家庭和工作位置,除非您专门设置它们.

我在 Google 官方文档中找到的任何地方都没有明确引用此数据的存储/检索,但 Google Now 中此数据的架构可在此处获得:Google Schema - Person

对于任何给定的个人实体,homeLocationworkLocation 属性与该数据一起存在.

或者(或除此之外)使用 Google 的 Plus 平台/Google Identity Platform,如果您有经过身份验证的用户,您可以按照描述进行 API 调用此处(带有示例) 获取当前用户的任何指定字段(包括当前位置、带有地址的组织(包括工作),如果用户提供的话).

以前的 SO 问题引用使用 oAuth 和原始谷歌地图提要 URL 来提取数据存在,但接受的答案有点不清楚,当我点击链接并尝试进行身份验证以测试它时,我收到了来自所有人的 404 错误其中:访问位置通过 Google Maps API 的特定帐户的我的地方"

也如在 Google 产品论坛帖子中此处 几年前,以前版本的 Google Maps Data API 允许访问我的地点,这正是您所需要的,但它在 2013 年被弃用并被删除.>

最后,我认为这是最好的方法,可能是 Google 使用的(如果它没有声明为 Google Now),即 Google Contacts API.用户存在于他们自己的联系人列表中,而 Google 通讯录的广泛 API 允许您使用标准标签(例如用户的家庭或工作单位)获取/设置地址.

此处详细介绍:Google 联系人服务 - 应用脚本

When in Google Inbox you go to snooze a message and select 'Pick place' it shows a list with your home and work address (from Google Now) populated as well as starred locations from your Google Maps profile. Other Google apps, like Keep also provide similar functionality.

I would like to implement this in my app but couldn't find the right API that exposes that information. Is that something that Google doesn't expose to 3rd parties (I guess there's room for abuse there)?

If not, how can this be implemented? What API has the data?

解决方案

Google Now utilizes analytics on your location data (on any and all devices signed into Google + location services enabled in your Google Account settings) to determine your home and work locations, unless you specifically set them.

The storage / retrieval of this data is not explicitly referenced anywhere that I have found in official Google documentation, but the schema in Google Now for this data is available here: Google Schema - Person

For any given person entity, a homeLocation and workLocation property exists with that data.

Alternatively (or in addition to), using Google's Plus Platform / Google Identity Platform, if you have an authenticated user, you can make an API call as described here (with examples) to get any of the specified fields for the current user (including currentLocation, organizations (including work) with addresses, if the user provided them).

A previous SO question that references using oAuth and raw Google Maps feed urls to pull the data exists, but the accepted answer is somewhat unclear and when I followed the links and attempted authenticated to test it out, I received 404 errors from all of them: Access locations in My Places of a particular account through Google Maps API

Also as in a Google Product Forums post here several years ago, a previous version of the Google Maps Data API allowed access to My Places, which is quintessentially exactly what you need, but it was deprecated and removed in 2013.

Finally, and this is the best approach in my opinion, and may be what Google uses (if it isn't declared to be Google Now), which is the Google Contacts API. A user exists in their own contact list, and the extensive API for Google Contacts allows you to get/set addresses with standard labels such as home or work for the user.

This is all detailed here: Google Contact Services - App Scripts

这篇关于像谷歌收件箱一样获取用户的家、工作和加星标的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆