mardi 7 avril 2015

fetch friends list from facebook sdk 4.0.1 in android with graph api 2.2

Code i used for fetching the list after doing some search is below



GraphRequestBatch batch = new GraphRequestBatch(
GraphRequest.newMyFriendsRequest(
accessToken,
new GraphRequest.GraphJSONArrayCallback() {
@Override
public void onCompleted(
JSONArray jsonArray,
GraphResponse response) {
// Application code for users friends
System.out.println("getFriendsData onCompleted : jsonArray " + jsonArray);
System.out.println("getFriendsData onCompleted : response " + response);
try {
JSONObject jsonObject = response.getJSONObject();
System.out.println("getFriendsData onCompleted : jsonObject " + jsonObject);
JSONObject summary = jsonObject.getJSONObject("summary");
System.out.println("getFriendsData onCompleted : summary total_count - " + summary.getString("total_count"));
} catch (Exception e) {
e.printStackTrace();
}
}
})

);
batch.addCallback(new GraphRequestBatch.Callback() {
@Override
public void onBatchCompleted(GraphRequestBatch graphRequests) {
// Application code for when the batch finishes
}
});
batch.executeAsync();

Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link,picture");


and the permission i get is accessToken : {AccessToken token:ACCESS_TOKEN_REMOVED permissions:[user_friends, basic_info]}


getRecentlyGrantedPermissions : [user_friends, basic_info]


getRecentlyDeniedPermissions : []


and the output of the graph function is -


response {Response: responseCode: 200, graphObject: {"summary":{"total_count":3},"data":[]}, error: null}


so can anyone please guide me to fetch the friend list of user .


Thanx in advance .


Aucun commentaire:

Enregistrer un commentaire