Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a contact's facebook id or url from native contacts / content resolver?

How to get the facebook id or url of a contacts that's been synced to the native contacts app via Facebook sync adapter?

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

I tried

ContactsContract.Data.CONTENT_URI
ContactsContract.CommonDataKinds.Email.CONTENT_URI
ContactsContract.CommonDataKinds.Phone.CONTENT_URI
ContactsContract.Contacts.CONTENT_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

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.

like image 831
Mathias Conradt Avatar asked Dec 22 '10 05:12

Mathias Conradt


People also ask

How to find a Facebook page URL?

Find Facebook URL for a Facebook Page or a Group Login to your Facebook account. Then, type the name of the Facebook page into the search bar and click search. To ensure that only Facebook Pages are returned, click Pages.

How do I find my Facebook user ID?

You’ll need to be using a computer with a web browser to find a user ID. 2 Sign in to Facebook. Type your username and password into the blanks at the top-right corner of the screen, then click Log In.

How to copy the profile URL for another person on Facebook?

Then, to open your profile, tap View your profile. Beneath your profile picture, tap the More button. Then, from the list of displayed options, tap Copy link to profile. Here are the steps to copy the profile URL for another person… On the top right of the Facebook App, tap the search icon. Type the name of the person into the search box.

Can I export a list of my contacts from Facebook?

In fact you can quite easily export just a list of your contacts. I’ll demonstrate how to do that, but be warned that you might be a bit disappointed in the results. Let’s have a look! I’ll go through the steps with Facebook’s desktop interface.


1 Answers

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

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.

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.

like image 200
Mathias Conradt Avatar answered Nov 15 '22 21:11

Mathias Conradt