我能够通过以下code访问ID,名字,姓氏,性别,以及GraphUser的电子邮件。 但是,我也需要访问的位置,朋友数,基本信息和工作公司。如何才能做到这一点?我试过其他计算器联系,并检查了Facebook的SDK链接,但没有得到一个突破。我可以提供code直接访问的方式相同,我已经有数据所需的字段? 我需要其他什么权限?
I am able to access the id, firstname, lastname, gender, and email of a GraphUser by using the following code. But, I also need access to "location", "number of friends", "basic info" and "work company". How can this be done? I have tried other stackoverflow links, and checked the Facebook SDK link, but not getting a break through. Could I be provided code to directly access the required fields in the same way as the data that I already have? What other permissions would I need?
loginBtn.setReadPermissions(Arrays.asList("public_profile", "email", "user_friends", "user_birthday", "read_friendlists"));
loginBtn.setUserInfoChangedCallback(new UserInfoChangedCallback() {
@Override
public void onUserInfoFetched(GraphUser user) {
if (user != null) {
login_text.setText("Please login to continue");
userDetails = new JSONObject();
try {
Log.d("user birthday", user.getBirthday());
userDetails.put("fbId", user.getId());
userDetails.put("firstName", user.getFirstName());
userDetails.put("lastName", user.getLastName());
userDetails.put("gender", user.getProperty("gender").toString());
userDetails.put("email", user.getProperty("email").toString());
} catch (JSONException e) {
Log.d("Error: ", "Error setting user settings in FBActivity");
}
} else {
//login_text.setText("You are not logged");
}
}
});
编辑:
我得到了一切,除了朋友的人都有的总数。这怎么可能做到。我已经通过您的链接消失了,看来我需要调用另一个GraphRequest链接。但我不认为。我想的朋友的总数(没有名字,没有详细说明,只数)。我已经加入了许可user_friends。什么code我应该写拿到多少?
I got everything except the total number of friends an individual has. How can that be done. I have gone through your links and it seems that I need to call another GraphRequest link. But I don't that. I want the total number of friends (no names, no details, just the number). I have added the permission "user_friends". What code should I write to get the number?
推荐答案
要得到朋友数,请参考以下链接:
To get number of friends please refer to the following link:
https://developers.facebook.com/文档/图-API /参考/ V2.4 /用户/朋友
需要的权限是: user_friends
,你已经包含..
Permissions needed would be: user_friends
, which you already have included..
您会得到朋友的场数摘要中的 TOTAL_COUNT
You'll get friends count in field 'summary' in the name of total_count
类似的问题:facebook API在Android上 - 我怎么能得到好友的号码,用户有
loginBtn.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
new GraphRequest(
loginResult.getAccessToken(),
"/me/friends",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.i("response", response.getJSONArray().toString()); //find the summary 'total_count' in the response
}
}
).executeAsync();
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException exception) {
}
});
相关推荐
最新文章