gpt4 book ai didi

java - 获取适用于 Android 的 Facebook 电子邮件 Api

转载 作者:行者123 更新时间:2023-12-01 11:28:37 26 4
gpt4 key购买 nike

我尝试获取用户的电子邮件,但无法获取。 profile.getProperty("email").toString(), profile.getEmail()..

我没有找到解决方案。

谢谢你。

private void updateUI() {

Profile profile = Profile.getCurrentProfile();
//if (enableButtons && profile != null) {
if (profile != null) {
System.out.println("Nombre: "+profile.getFirstName()+" "+profile.getLastName());
} else {
profilePictureView.setProfileId(null);
greeting.setText(null);
}
}

最佳答案

首先您需要设置权限,例如

loginButton.setReadPermissions(Arrays.asList("public_profile, email, user_birthday, user_friends"));

并在您的Activity中执行此操作

private LoginButton loginButton;
CallbackManager callbackManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

loginButton = (LoginButton) findViewById(R.id.login_button);

loginButton.setReadPermissions(Arrays.asList("public_profile, email, user_birthday"));

callbackManager = CallbackManager.Factory.create();

// Callback registration
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Application code
Log.v("LoginActivity", response.toString());
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender, birthday");
request.setParameters(parameters);
request.executeAsync();


}

@Override
public void onCancel() {
// App code
Log.v("LoginActivity", "cancel");
}

@Override
public void onError(FacebookException exception) {
// App code
Log.v("LoginActivity", exception.getCause().toString());
}
});


}

关于java - 获取适用于 Android 的 Facebook 电子邮件 Api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30617712/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com