gpt4 book ai didi

android - Facebook 不在最新的 sdk 4.4.1 中提供电子邮件?

转载 作者:行者123 更新时间:2023-11-29 01:30:20 25 4
gpt4 key购买 nike

我已经指定了“电子邮件”权限,但我无法使用最新的 facebook sdk 4.4.1 获取电子邮件...如果有人有解决方案,请指导我。提前致谢...

public void loginToFacebook() {

mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);

if (access_token != null) {
facebook.setAccessToken(access_token);

btnFbLogin.setVisibility(View.INVISIBLE);

// Making get profile button visible
btnFbGetProfile.setVisibility(View.VISIBLE);

// Making post to wall visible
btnPostToWall.setVisibility(View.VISIBLE);

// Making show access tokens button visible
btnShowAccessTokens.setVisibility(View.VISIBLE);

Log.d("FB Sessions", "" + facebook.isSessionValid());
}

if (expires != 0) {
facebook.setAccessExpires(expires);
}

if (!facebook.isSessionValid()) {
facebook.authorize(this,
new String[] { "email", "publish_stream" },
new DialogListener() {

@Override
public void onCancel() {
// Function to handle cancel event
}

@Override
public void onComplete(Bundle values) {
// Function to handle complete event
// Edit Preferences and update facebook acess_token
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token",
facebook.getAccessToken());
editor.putLong("access_expires",
facebook.getAccessExpires());
editor.commit();

// Making Login button invisible
btnFbLogin.setVisibility(View.INVISIBLE);

// Making logout Button visible
btnFbGetProfile.setVisibility(View.VISIBLE);

// Making post to wall visible
btnPostToWall.setVisibility(View.VISIBLE);

// Making show access tokens button visible
btnShowAccessTokens.setVisibility(View.VISIBLE);
}

@Override
public void onError(DialogError error) {
// Function to handle error

}

@Override
public void onFacebookError(FacebookError fberror) {
// Function to handle Facebook errors

}

});
}
}


public void getProfileInformation() {
mAsyncRunner.request("me", new RequestListener() {
@Override
public void onComplete(String response, Object state) {
Log.d("Profile", response);
String json = response;
try {
// Facebook Profile JSON data
JSONObject profile = new JSONObject(json);

// getting name of the user
final String name = profile.getString("name");

// getting email of the user
final String email = profile.getString("email");

runOnUiThread(new Runnable() {

@Override
public void run() {
Toast.makeText(getApplicationContext(), "Name: " + name + "\nEmail: " + email, Toast.LENGTH_LONG).show();
}

});


} catch (JSONException e) {
e.printStackTrace();
}
}

@Override
public void onIOException(IOException e, Object state) {
}

@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
}

@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
}

@Override
public void onFacebookError(FacebookError e, Object state) {
}
});
}

这是我的代码,但我没有收到电子邮件,你能导航一下我可以把它放在代码下面的什么地方吗。

最佳答案

您需要通过请求传递您需要的字段,例如:

Bundle parameters = new Bundle();
parameters.putString("fields","id,name,email,gender, birthday");
GraphRequest.setParameters(parameters);
GraphRequest.executeAsync();

关于android - Facebook 不在最新的 sdk 4.4.1 中提供电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31585825/

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