0
获取facebook用户个人资料信息,包括用户电子邮件,我已经尝试并成功获取所需的信息,除了电子邮件地址,因为每个开发者页面我必须使新的API请求获得电子邮件和位置的详细信息,有人建议我如何使在下面的代码 这个API请求,这是我怎么想提出请求来获取Facebook的用户配置文件数据如何使用facebook sdk 4.0in android
// 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;
}
这是建议由下式给出developer page以获取电子邮件如何在我的代码中调用api,请帮助
方法executeBatchAsync(GraphRequest)是未定义的类型请求和会话不能得到解决,Request.GraphUserCallback不能被解析为类型和方法executeBatchAsync(GraphRequest)未定义类型请求 – Prabha1
您应该从facebook sdk导入所有类。 import com.facebook.Request; import com.facebook.Response; import com.facebook.Session; –
是的,是的,我已经尝试过所有,但没有运气意味着这些软件包没有导入您正在使用的Facebook的SDK? – Prabha1