我已经使用facebook sdk集成创建了示例应用。现在我可以登录facebook也可以从facebook获取一些基本信息。但是没有从“ GraphUser ”生日那天我注意到生日我需要设置我已经设置的权限“ user_birthday ”。我不知道回答有什么问题。
private static Session openActiveSession(Activity activity, boolean allowLoginUI, Session.StatusCallback callback, List permissions) {
Session.OpenRequest openRequest = new Session.OpenRequest(activity).setPermissions(permissions).setCallback(callback);
Session session = new Session.Builder(activity).build();
if (SessionState.CREATED_TOKEN_LOADED.equals(session.getState()) || allowLoginUI) {
Session.setActiveSession(session);
session.openForRead(openRequest);
return session;
}
return null;
}
private void startFacebookLogin() {
openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
//make request to the /me API
Log.e("sessionOpened", "true");
Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
String firstName = user.getFirstName();
String lastName = user.getLastName();
String id = user.getId();
String email = user.getProperty("email").toString();
Log.d("AllData", user.toString());
Log.e("facebookId", id);
Log.e("firstName", firstName);
Log.e("lastName", lastName);
Log.e("email", email);
String Birthdate=user.getBirthday();
Log.e("Birthdate", Birthdate+"::Birthdate");
}
}
}).executeAsync();
}
}
}, Arrays.asList(
new String[] { "email", "user_location", "user_birthday","user_likes" }));
}
GraphUser respose
GraphObject{graphObjectClass=GraphUser, state={"id":"…..","first_name":"…..","timezone":5.5,"email":"…..@gmail.com","verified":false,"name":"…..","locale":"en_US","link":"https:\/\/www.facebook.com\/app_scoped_user_id\/....\/","last_name":"…..","gender":"male","updated_time":"2012-12-21T06:54:19+0000"}}
答案 0 :(得分:2)
您是否正在尝试使用Facebook应用的管理员/测试人员/开发者用户?如果没有,原因是如果您申请扩展权限,则需要通过Facebook应用审核流程获取您的应用,如下所述:
https://developers.facebook.com/docs/apps/review/login#do-you-need-review