How to import facebook contacts into my app built

2019-04-14 12:37发布

I am developing voip application in android.And i need to import contacts with name and phone number from facebook, twitter, LinkedIn, Google(Buzz,Orkut,Contacts,Gmail) etc.I am searching for the api example.But i could see only examples for posting status into those site and there is no example for importing contacts from facebook,orkut or twitter etc,.Is there any api's for importing contacts with example?

1条回答
淡お忘
2楼-- · 2019-04-14 12:52

You can use the official facebook-android-sdk, and do something like this after being authenticated

Bundle parameters = new Bundle();
parameters.putString( "fields", "id,name" ); //see the link below to have the fields list

String response = facebook.request( "me/friends", parameters ); 

JSONObject json = Util.parseJson( response );

JSONArray data = json.getJSONArray( "data" );

for ( int i = 0, size = data.length(); i < size; i++ )
{
    JSONObject friend = data.getJSONObject( i );

    String id = friend.getString( "id" );
    String name = friend.getString( "name" );
    (...)
}

Fields list

查看更多
登录 后发表回答