这是我从Facebook获得的JSONObject
。
{
"id": "673712949465129",
"name": "Shyam SelvaKumar",
"link": "https:\/\/www.facebook.com\/app_scoped_user_id\/673712949465129\/",
"picture": {
"data": {
"is_silhouette": false,
"url": "https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-1\/p50x50\/13567404_583364415166650_2716003405410548102_n.jpg?oh=16aa11f12003863ac931a9ec744f3b43&oe=58DF0121"
}
}
}
我没有收到回复的电子邮件值。
答案 0 :(得分:0)
尝试使用其他用户个人资料。 因为Facebook将为您提供用户的电子邮件ID,当且该用户的确认电子邮件ID与其帐户相关联。
答案 1 :(得分:0)
你的Facebook Graph request
应该是这样的:
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
Log.v("FACEBOOK LOGIN", response.toString());
// Application code
try {
String fb_id = object.getString("id");
String fb_name = object.getString("name");
String profilePicUrl = "https://graph.facebook.com/" + fb_id + "/picture?width=200&height=200";
String fb_gender = object.getString("gender");
String fb_email = object.getString("email");
String fb_birthday = object.getString("birthday");
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender,birthday,picture.type(small)");
request.setParameters(parameters);
request.executeAsync();
} catch (Exception e) {
Log.d("ERROR", e.toString())
}
您还需要在setReadpermission
loginButtton
loginButton.setReadPermissions(Arrays.asList(
"public_profile", "email", "user_birthday", "user_friends"));
loginButton.registerCallback(callbackManager, callback);
Facebook Sdk
另外,first()
如果隐私不公开,则不会返回您的电子邮件ID