我试图让用户email
与AccessToken
,我从Facebook SDK
的Android SDK Facebook的问题AcccessToken
拿到如果我使用
Graph API Explorer
的AccessToken
我能得到id
,name
和email
不要紧,如果我使用浏览器或OkHttp
:"https://graph.facebook.com/" + user_id + "?fields=email,name&access_token=" + access_token_from_graph_explorer
我得到这样的性反应:
{
"email": "[email protected]",
"name": "John Doe",
"id": "4545"
}
如果我用AccessToken.getCurrentAccessToken().getToken()
方法采取token
,我不JSONObject
得到email
。
- 使用
Graph Explorer
我可以看到我的id
。我试图使请求是这样的:
"https://graph.facebook.com/me?fields=email,name&access_token="
这:
"https://graph.facebook.com/" + id + "?fields=email,name&access_token="
在第二个变体我已经"Unsupported get request. Object with ID 'xxxxxxxxxxx' does not exist, cannot be loaded due to missing permissions...
,而用我的id
。当我试图使用id
的另一个user
我仍然没有得到email
。
Bundle bundle = new Bundle();
bundle.putString("fields", "email,name");
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"me",
bundle,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
System.out.println("data = " + response.toString());
}
}
).executeAsync();
有了这个变体,我也没有完成email
。
我很困惑。告诉我,我如何检索用户电子邮件。
3.After登录我尝试:
public void onSuccess(LoginResult loginResult) {
System.out.println("succses =" + loginResult.getAccessToken().getToken());
accessToken = loginResult.getAccessToken();
GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject user, GraphResponse graphResponse) {
Log.d("TAG", user.optString("email"));
Log.d("TAG", user.optString("name"));
Log.d("TAG", user.optString("id"));
init();
}
}).executeAsync();
}
但我没有看到TAG
与电子邮件 附: graph explorer
中的所有权限均已打开。
答案尝试在计算器这个答案......我面临同样的问题... http://stackoverflow.com/a/33412596 –
@ExceptionLover好的,谢谢。这有帮助。 –
PLZ接受我的回答... !! –