Facebook SDK 3.22 (android) - me/friends return 错误的用户好友 ID
Facebook SDK 3.22 (android) - me/friends return wrong user's friends id
我想让我的应用程序获取也使用过该应用程序的用户好友的 ID 和名称,并通过名称找到我需要的 ID。然后我想使用带参数 "TO" 到 post 的提要对话框到朋友的墙上。我以为这很容易。只需使用 me/friends
。这是请求:
if(session.getState().isOpened()){
Log.i(TAG, "Creating request");
Request friendRequest = new Request(session, "/me/friends", null, HttpMethod.GET, new Request.Callback() {
public void onCompleted(Response response) {
Log.w(TAG, "Complete!" + response.toString());
JSONArray usersArrays = new JSONArray();
try {
Log.i(TAG, "Converting to userObject");
usersArrays = response.getGraphObject().getInnerJSONObject().getJSONArray("data");
for (int i = 0; i < usersArrays.length(); i++){
Log.i(TAG, "Reading " + i + " user");
JSONObject user = usersArrays.getJSONObject(i);
Log.i(TAG, "Getting name and id");
String userId = user.getString("id");
String userName = user.getString("name");
Log.i(TAG, "Now checking: " + userName + " with id: " + userId);
if (userName.equals(name)){
Log.w(TAG, "He was found! Here is his id: " + userId);
postToWall(userId);
} else if (i == (usersArrays.length() - 1)){
Log.e(TAG, name + " does not use the app yet!");
//no ways
}
}
} catch (JSONException e) {
Log.e(TAG, "Error: " + e);
Toast.makeText(context, "Error", Toast.LENGTH_LONG).show();
}
}
}
);
Log.i(TAG, "Sending request");
friendRequest.executeAndWait();
这是我的回复:
{Response: responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"summary":{"total_count":46},"data":[{"id":"383791018465143","name":"Friend Name"}],"paging":{"next":"..."}}}, error: null, isFromCache:false}
然后我找到 this 网站并决定找出朋友的 ID。不一样。
使用提要对话框时,我的应用程序因 facebook 错误而崩溃:incorrect user
。我该怎么办?
提前致谢,谢尔盖
正如@MingLi 所说,我无法获取用户好友的 Facebook id
我想让我的应用程序获取也使用过该应用程序的用户好友的 ID 和名称,并通过名称找到我需要的 ID。然后我想使用带参数 "TO" 到 post 的提要对话框到朋友的墙上。我以为这很容易。只需使用 me/friends
。这是请求:
if(session.getState().isOpened()){
Log.i(TAG, "Creating request");
Request friendRequest = new Request(session, "/me/friends", null, HttpMethod.GET, new Request.Callback() {
public void onCompleted(Response response) {
Log.w(TAG, "Complete!" + response.toString());
JSONArray usersArrays = new JSONArray();
try {
Log.i(TAG, "Converting to userObject");
usersArrays = response.getGraphObject().getInnerJSONObject().getJSONArray("data");
for (int i = 0; i < usersArrays.length(); i++){
Log.i(TAG, "Reading " + i + " user");
JSONObject user = usersArrays.getJSONObject(i);
Log.i(TAG, "Getting name and id");
String userId = user.getString("id");
String userName = user.getString("name");
Log.i(TAG, "Now checking: " + userName + " with id: " + userId);
if (userName.equals(name)){
Log.w(TAG, "He was found! Here is his id: " + userId);
postToWall(userId);
} else if (i == (usersArrays.length() - 1)){
Log.e(TAG, name + " does not use the app yet!");
//no ways
}
}
} catch (JSONException e) {
Log.e(TAG, "Error: " + e);
Toast.makeText(context, "Error", Toast.LENGTH_LONG).show();
}
}
}
);
Log.i(TAG, "Sending request");
friendRequest.executeAndWait();
这是我的回复:
{Response: responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"summary":{"total_count":46},"data":[{"id":"383791018465143","name":"Friend Name"}],"paging":{"next":"..."}}}, error: null, isFromCache:false}
然后我找到 this 网站并决定找出朋友的 ID。不一样。
使用提要对话框时,我的应用程序因 facebook 错误而崩溃:incorrect user
。我该怎么办?
提前致谢,谢尔盖
正如@MingLi 所说,我无法获取用户好友的 Facebook id