如何在android中使用facebook sdk 4.0为获取用户电子邮件进行api调用
尝试获取facebook用户配置文件信息,包括用户电子邮件,我已尝试并成功获取除电子邮件地址以外的所需信息,根据开发者页面,我必须提出新的api请求以获取电子邮件和位置详细信息,有人建议我如何在以下代码中提出此api请求 这就是我请求获取facebook用户档案数据的方式如何在android中使用facebook sdk 4.0为获取用户电子邮件进行api调用,android,email,facebook-sdk-4.0,Android,Email,Facebook Sdk 4.0,尝试获取facebook用户配置文件信息,包括用户电子邮件,我已尝试并成功获取除电子邮件地址以外的所需信息,根据开发者页面,我必须提出新的api请求以获取电子邮件和位置详细信息,有人建议我如何在以下代码中提出此api请求 这就是我请求获取facebook用户档案数据的方式 // Callback registration loginButton.registerCallback(callbackManager, new FacebookCallback<Lo
// Callback registration
loginButton.registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
// login ok get access token
GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object,
GraphResponse response) {
if (BuildConfig.DEBUG) {
FacebookSdk.setIsDebugEnabled(true);
FacebookSdk
.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
System.out
.println("AccessToken.getCurrentAccessToken()"
+ AccessToken
.getCurrentAccessToken()
.toString());
Profile.getCurrentProfile().getId();
Profile.getCurrentProfile().getFirstName();
Profile.getCurrentProfile().getLastName();
Profile.getCurrentProfile().getProfilePictureUri(50, 50);
}
}
});
Bundle parameters = new Bundle();
parameters
.putString("fields",
"id,firstName,lastName,name,email,gender,birthday,address");
request.setParameters(parameters);
request.executeAsync();
Intent loginintent = new Intent(getActivity(),
EditProfile.class);
startActivity(loginintent);
System.out.println("XXXX " + getId());
makeJsonObjReq();
}
@Override
public void onCancel() {
// App code
}
@Override
public void onError(FacebookException exception) {
// App code
}
});
return view;
}
这是获得电子邮件如何在我的代码中调用api的建议,请帮助这将对您有用
final Request request = Request.newMeRequest(Session.getActiveSession(), new Request.GraphUserCallback() {
@Override
public void onCompleted(final GraphUser use, final Response response) {
final String email = user.asMap().get("email").toString();
}
});
Request.executeBatchAsync(request);
用于在v2.3中获取用户信息的新图形api
new Request(session,"/{user-id}",null,HttpMethod.GET,new Request.Callback(){
public void onCompleted(Response response) {
/* handle the result */
}
}).executeAsync();
类型请求的方法executeBatchAsyncGraphRequest未定义,会话无法解析,Request.GraphUserCallback无法解析为类型,类型请求的方法executeBatchAsyncGraphRequest未定义。您应该从facebook sdk导入所有类。导入com.facebook.Request;导入com.facebook.Response;导入com.facebook.Session;是的,是的,我已经尝试了所有的,但没有运气意味着这些软件包没有导入你正在使用的facebook sdk?com.facebook.android:facebook android sdk:3.20.0+我最近已经实现了3.5,但现在我想使用4.0,我想很少有类会被旧sdk弃用,由于几次更新,facebook sdk集成变得非常繁忙