我想在我的Android应用程序中显示Facebook朋友列表
大约2个月后,我想结识我的朋友(他们单击了“继续使用Facebook”按钮),但是每次图表给我一个包含实际朋友数的空数组..有人可以帮助我吗?
那是我的代码的结果:
{Response: responseCode: 200, graphObject: {"data":[],"summary":{"total_count":104}}, error: null}
登录代码
FacebookSdk.sdkInitialize(this.getApplicationContext());
callbackManager = CallbackManager.Factory.create();
loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setTextColor(Color.WHITE);
loginButton.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
loginButton.setCompoundDrawablePadding(0);
loginButton.setReadPermissions("user_friends");
结识朋友:
// Callback registration
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
GraphRequest request = GraphRequest.newGraphPathRequest(
loginResult.getAccessToken(),
"/"+loginResult.getAccessToken().getUserId()+"/friends",
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
// Insert your code here
Log.d("neo9",response.toString());
}
});
request.executeAsync();
}
@Override
public void onCancel() {
// App code
Log.d("neo7","cancel");
}
@Override
public void onError(FacebookException exception) {
// App code
Log.d("neo7",exception.getMessage());
}
});