如何从本机联系人/内容解析器获取联系人的 facebook id 或 url? [英] How to get a contact's facebook id or url from native contacts / content resolver?

查看:43
本文介绍了如何从本机联系人/内容解析器获取联系人的 facebook id 或 url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取已通过 Facebook 同步适配器同步到本机通讯录应用的联系人的 facebook id 或 url?

我浏览了不同的网址,但没有看到任何关于 Facebook 的信息.

I went through different urls, but didn't see any info regarding facebook.

我试过了

ContactsContract.Data.CONTENT_URI
ContactsContract.CommonDataKinds.Email.CONTENT_URI
ContactsContract.CommonDataKinds.Phone.CONTENT_URI
ContactsContract.Contacts.CONTENT_URI

作为已经在下面代码中的 URI:

as URIs already in the code below:

    Uri uri = ContactsContract.Data.CONTENT_URI;
    Cursor c = getContentResolver().query(uri, null, null, null, null);
    while (c.moveToNext()) {
        for (int i=0; i<c.getColumnCount(); i++) {
            Log.d(TAG, c.getColumnName(i) + ": " +  c.getString(i));
        }
        Log.d(TAG, "==================================");

    }

我确实得到了一个列值,如

I do get a column value like

contact_status_res_package: com.facebook.katana

在此转储中,我还获得了联系人状态(contact_status 列),但我在任何地方都看不到此联系人的 Facebook 网址或 ID.

in this dump, and I also get the contacts status (contact_status column), but nowhere do I see the facebook url or id of this contact.

推荐答案

在 Google Group (http://groups.google.com/group/android-developers/browse_thread/thread/95110dd7a1e1e0b4) 上得到回复:

Got the reply from on the Google Group (http://groups.google.com/group/android-developers/browse_thread/thread/95110dd7a1e1e0b4):

通过以下方式访问 Facebook 好友联系人提供程序仅限于提供商提供的少数系统应用程序本身.其他应用不能读取该数据.

Access to Facebook friends via the contacts provider is restricted to a handful of system apps by the provider itself. Other applications cannot read that data.

因此,现在我通过 FB Graph api (http://graph.facebook.com/me/friends) 获取缓存所有联系人姓名/id 映射并将其用于 id 查找.

Therefore now I fetch an cache all contact names/id mappings via FB Graph api (http://graph.facebook.com/me/friends) and use that for the id lookup.

这篇关于如何从本机联系人/内容解析器获取联系人的 facebook id 或 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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