我尝试过使用这些引用: https://developers.facebook.com/docs/graph-api/reference/user/friends
How to get friend list from Facebook using Android Facebook sdk?
How to fetch facebook friend list in android ? I am using facebook sdk 4.0.1
我也尝试了其他参考资料,但我无法解决我的问题。
这是我的代码
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(final LoginResult loginResult) {
GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
System.out.println("Facebook recponse = "+response);
try {
sSocialId = object.getString("id");
if (object.has("email")) {
sEmail = object.getString("email");
}
sSocialType = "fb";
sFirstname = object.getString("first_name");
sLastname = object.getString("last_name");
String gender = object.getString("gender");
sGender = gender;
sUserImageUrl = "https://graph.facebook.com/" + sSocialId + "/picture?type=large";
} catch (JSONException e) {
e.printStackTrace();
}
AccessToken token1 = AccessToken.getCurrentAccessToken();
/*
make the API call
*/
new GraphRequest(loginResult.getAccessToken(),
"/me/friendlists",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
try {
JSONArray rawName = response.getJSONObject().getJSONArray("data");
String friendList = "{\"friendlist\":" + rawName.toString() + "}";
Log.d("TAG","response of friendlist is : " + friendList);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
).executeAsync();
Toast.makeText(HomeActivity.this,"Login successfull...",Toast.LENGTH_LONG).show();
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id, first_name, last_name,gender, email,picture,friends{id,name,picture}");
request.setParameters(parameters);
request.executeAsync();
}
@Override
public void onCancel() {
Toast.makeText(HomeActivity.this, "Facebook login cancelled", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(FacebookException exception) {
Toast.makeText(HomeActivity.this, "Error in Facebook login", Toast.LENGTH_SHORT).show();
}
});
答案 0 :(得分:0)
XWPFTableCell
这里fbFreindsList是一个modelClass fbFriends的列表,这里我只取fbfriends的id,你也可以根据你的要求获取数据