我在原生 Android 中使用 facebook sdk 3.5。这就是我获取我的 facebook 朋友的 id/name 的方式:
private void onSessionStateChange(final Session session,
SessionState state, Exception exception) {
System.out.println("onSessionStateChanged");
if (session != null && session.isOpened()) {
if (state.equals(SessionState.OPENED_TOKEN_UPDATED)) {
tokenUpdated();
} else {
getUserRequest(session);
getFriendsRequest(session);
}
} else {
profilePictureView.setProfileId(null);
userNameView.setText("");
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(getActivity(), requestCode,
resultCode, data);
// uiHelper.onActivityResult(requestCode, resultCode, data,
// nativeDialogCallback);
}
private void getFriendsRequest(Session session) {
session.requestNewReadPermissions(new NewPermissionsRequest(
getActivity(), PERMISSIONS));
final ProgressDialog dialog = new ProgressDialog(getActivity());
// get friends details
Request request = Request.newMyFriendsRequest(session,
new Request.GraphUserListCallback() {
@Override
public void onCompleted(List<GraphUser> users,
Response response) {
// if no errors
if (response.getError() == null) {
if (users != null) {
for (GraphUser user : users) {
FacebookFriend fb = new FacebookFriend(user
.getId(), user.getName(), "", "",
"", 0);
friends.add(fb);
}
....
}
}
现在的回应是:
{Response: responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"data":[{"id":"213","name":"Test name"}]}}, error: null, isFromCache:false}
一切都很好,但电子邮件(如果共享)、位置、用户名等详细信息不在:
GraphObject{graphObjectClass=GraphUser, state={"id":"60711232217","name":"Test"}}
我应该在哪里设置权限?这是我的要求:
{Request: session: {Session state:OPENED, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[email, user_location, user_friends, friends_location, basic_info]}, appId:111111}, graphPath: me/friends, graphObject: null, restMethod: null, httpMethod: GET, parameters: Bundle[{access_token=dasdasdasdasdsada, format=json, sdk=android, migration_bundle=fbsdk:20130708}]}
我应该在哪里添加这些权限以获得更多详细信息?
谢谢你。