如何从 Android 手机读取 google.com/contacts?

发布于 2024-08-20 17:20:08 字数 427 浏览 10 评论 0原文

在我的 Android 应用程序中,我想从 google.com/contacts 检索生日字段,因为该字段在 Android 联系人应用程序中未同步。 我怎样才能拥有谷歌通讯录的读取权限?

我看到了 Google 通讯录 API,我是否必须使用它?哪一个? 便携版本

或者有没有一种简单的方法来读取这些联系人,就像 Android 在同步时所做的那样?

提前致谢

In my android application, I would like to retrieve the birthday field from google.com/contacts, as this field isn't synchronised in the android contacts application.
How can I have a read access to google contacts ?

I saw the Google contacts APIs, did I have to use it ? which one ? the Portable version ?

Or is there a simple way to read these contacts, as Android does when there is a synchronisation ?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朮生 2024-08-27 17:20:08

在AccountManager被重新发布之前,曾经有过一次黑客攻击,大约一年前我在android开发者小组上启动了一个线程,但它已经被删除了。有一个未记录的方法,您必须通过反射来访问。我现在似乎在任何地方都找不到它,就像谷歌已经删除了该线程或其他东西一样。我在下面发现了类似的东西,但这不是我正在工作的东西。

http://donpark.org/blog/2009/01/ 24/android-client-side-oauth

在最坏的情况下,现在推出的大多数设备最终都会获得 2.1。因此,您可以让他们登录,然后验证并从 google 获取身份验证密钥,如果他们使用 2.1,请使用 AccountManager,不要用凭据打扰他们。类似于下面的

WebRequest req = HttpWebRequest.Create(
@"https://www.google.com/accounts/ClientLogin?    accountType=GOOGLE&[email protected]&Passwd=pass&service=gbase&source=sadboy");
WebResponse resp = req.GetResponse();

string all;
using (StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream()))
    all = sr.ReadToEnd().Trim();

int auth = all.IndexOf("auth=");
string auth = all.Substring(auth, all.Length - auth);

https://developer.android.com/about/dashboards/index.html

There used to be a hack before the AccountManager was reased, I started a thread about a year ago on the android developer group, but it has been removed. There was an undocumented method that you had to access through reflection. I can't seem to find it anywhere now, like google has deleted the thread or something. I found something similar below, but it's not the one I had working.

http://donpark.org/blog/2009/01/24/android-client-side-oauth

At worst case, most devices that are out now, should eventual get 2.1. So you could just make them login then validate and get the auth key from google, and if they are on 2.1 use the AccountManager and don't bother them with the credentials. something like below

WebRequest req = HttpWebRequest.Create(
@"https://www.google.com/accounts/ClientLogin?    accountType=GOOGLE&[email protected]&Passwd=pass&service=gbase&source=sadboy");
WebResponse resp = req.GetResponse();

string all;
using (StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream()))
    all = sr.ReadToEnd().Trim();

int auth = all.IndexOf("auth=");
string auth = all.Substring(auth, all.Length - auth);

https://developer.android.com/about/dashboards/index.html

尐籹人 2024-08-27 17:20:08

从android 2.0开始使用AccountManager应该是可能的。

没有教程或示例,我无法访问任何 >=2.0 的设备来尝试。

请参阅 http://code.google.com/p/android /issues/detail?id=1073#c28

据我了解,您应该能够获取 Google 帐户的AuthToken 并将其传递到授权标头中,如下授权:GoogleLogin auth=yourAuthToken

It should be possible since android 2.0 using AccountManager.

There are no tutorials nor samples, I don't have access to any >=2.0 device to try it out.

See http://code.google.com/p/android/issues/detail?id=1073#c28

As I understand you should be able to getAuthToken fo Google account and pass it in Authorization header as here Authorization: GoogleLogin auth=yourAuthToken

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文