代码之家  ›  专栏  ›  技术社区  ›  tbruyelle

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

  •  3
  • tbruyelle  · 技术社区  · 15 年前

    在我的Android应用程序中,我想从google.com/contacts检索生日字段,因为这个字段在Android联系人应用程序中不同步。 我怎样才能访问谷歌联系人?

    我看到了 Google contacts APIs ,我必须使用它吗?哪一个?这个 Portable version ?

    还是有一种简单的方法来读取这些联系人,就像Android在同步时那样?

    提前谢谢

    2 回复  |  直到 7 年前
        1
  •  3
  •   Vadim Kotov First Zero    7 年前

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

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

    在最坏的情况下,大多数现在已经退出的设备最终应该得到2.1。所以你可以让他们登录,然后验证并从谷歌获得认证密钥,如果他们在2.1上,使用accountmanager,不要用证书打扰他们。像下面这样

    WebRequest req = HttpWebRequest.Create(
    @"https://www.google.com/accounts/ClientLogin?    accountType=GOOGLE&Email=them@gmail.com&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

        2
  •  1
  •   skyman    14 年前

    这应该是可能的,因为Android 2.0使用了AccountManager。

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

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

    据我所知,您应该能够获取google帐户的authtoken并将其作为这里的authorization:googlelogin auth=yourauthtoken传递到authorization头中。

    推荐文章