目前我正在使用facebook sdk 4.4.0,现在我想用他们使用我的应用程序的emailid获取朋友,或者他们至少登录了我的应用程序。
我推荐这个 - https://developers.facebook.com/docs/graph-api/reference/v2.4/user/friends
我该怎么做?
答案 0 :(得分:0)
您可以通过BatchRequest
GraphRequestBatch batch = new GraphRequestBatch(GraphRequest.newMyFriendsRequest(
accesstoken,
new GraphRequest.GraphJSONArrayCallback() {
@Override
public void onCompleted(JSONArray jsonArray, GraphResponse response) {
System.out.println("jsonArray: "+jsonArray);
System.out.println("GraphResponse: "+response);
try {
ArrayList<Friend_List_Load> item_details = new ArrayList<Friend_List_Load>();
for(int i=0; i<jsonArray.length();i++){
JSONObject c=jsonArray.getJSONObject(i);
System.out.println("id: "+c.getString(PROFILE_ID));
System.out.println("name: "+c.getString(NAME));
FriendListAdapter frndadapter=new FriendListAdapter(FriendList.this,item_details);
item_details.add(new Friend_List_Load(c.getString(NAME),c.getString(PROFILE_ID)));
lv_friends.setAdapter(frndadapter);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}),
GraphRequest.newMeRequest(accesstoken, new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
System.out.println("meJSONObject: "+object);
System.out.println("meGraphResponse: "+response);
}
})
);
batch.addCallback(new GraphRequestBatch.Callback() {
@Override
public void onBatchCompleted(GraphRequestBatch graphRequests) {
//Log.i(TAG, "onCompleted: graphRequests "+ graphRequests);
}
});
batch.executeAsync();
在onCompleted
中,您可以获得回复。