I have the following code and what I want to obtain is user's friends names, user's friends profile pictures and user's friends facebook id:
public void testFunction(final com.facebook.AccessToken access_token){
GraphRequest request = GraphRequest.newMeRequest(
access_token,
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
if(object != null) {
Log.wtf("FIRST", "JSONOBJECT: IS NULL");
}else {
Log.wtf("FIRST", "JSONOBJECT: " + object.toString());
}
if(response != null) {
Log.wtf("FIRST", "RESPONSE: IS NULL");
}else {
Log.wtf("FIRST","response: "+response.toString());
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link");
request.setParameters(parameters);
request.executeAsync();
}
public void getFriendsInformation(final com.facebook.AccessToken access_token) {
GraphRequestBatch batch = new GraphRequestBatch(
GraphRequest.newMeRequest(
access_token,
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject jsonObject,
GraphResponse response) {
if(jsonObject != null) {
Log.wtf("FIRST", "JSONOBJECT: IS NULL");
}else {
Log.wtf("FIRST", "JSONOBJECT: " + jsonObject.toString());
}
if(response != null) {
Log.wtf("FIRST", "RESPONSE: IS NULL");
}else {
Log.wtf("FIRST","response: "+response.toString());
}
// Application code for user
}
}),
GraphRequest.newMyFriendsRequest(
access_token,
new GraphRequest.GraphJSONArrayCallback() {
@Override
public void onCompleted(
JSONArray jsonArray,
GraphResponse response) {
if(jsonArray != null) {
Log.wtf("SECOND", "jsonArray: IS NULL");
}else {
Log.wtf("SECOND", "jsonArray: " + jsonArray.toString());
}
if(response != null) {
Log.wtf("SECOND", "RESPONSE: IS NULL");
}else {
Log.wtf("SECOND","response: "+response.toString());
}
}
})
);
batch.addCallback(new GraphRequestBatch.Callback() {
@Override
public void onBatchCompleted(GraphRequestBatch graphRequests) {
// Application code for when the batch finishes
}
});
batch.executeAsync();
}
When I run the code with the accessToken IS NULL is printed in the designated logs. Shouldn't this work?
Aucun commentaire:
Enregistrer un commentaire