In my Android application I want to display Facebook friend list with their information. For retrieving friend'd data I used following code :-
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
if (state.isOpened()) {
Log.i(TAG, "Logged in...");
Request friendRequest = Request.newMyFriendsRequest(session,
new GraphUserListCallback(){
@Override
public void onCompleted(List<GraphUser> users,
Response response) {
Log.i("INFO", response.toString());
GraphObject graphObject = response.getGraphObject();
if (graphObject != null) {
JSONObject jsonObject = graphObject.getInnerJSONObject();
try {
JSONArray array = jsonObject.getJSONArray("data");
//code to store data
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
Bundle params = new Bundle();
params.putString("fields", "id, name , picture");
friendRequest.setParameters(params);
friendRequest.executeAsync();
} else if (state.isClosed()) {
Log.i(TAG, "Logged out...");
}
}
But when I run the code and print log message as per this line from code :-
Log.i("INFO", response.toString());
I got following log message :-
INFO: {Response: responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"data":[],"summary":{"total_count":1029}}}, error: null, isFromCache:false}
which states correct facebook friend "1029" but actual data is null "data":[]. How to retrieve correct data? Kindly correct me.
EDIT1
Now it is confirmed that we can get only get friend list who have installed same app.I used same code as above mention, only single line of change :-
params.putString("fields", "id, name , birthday");
I want to access friends birthday as well.I put all necessary permissions for same as follows
"read_friendlists","friends_birthday","read_stream", "offline_access"
But response only contains id and name but not birthdate.
Kindly suggest needful.
Kindly provide solution.