user_friends列表是空的Facebook SDK 3.14.1

时间:2014-06-01 14:13:52

标签: facebook-graph-api-v2.0

使用此代码,我想提取我的朋友列表,并作为我的朋友的所有最后签到的下一步,但列表始终为空。

public void onClick(View v) {
            String fqlQuery = "SELECT uid,name,pic_square FROM user WHERE uid IN "
                    + "(SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 25)";
            Bundle params = new Bundle();
            params.putString("q", fqlQuery);
            Session session = Session.getActiveSession();
            Request request = new Request(session, "/fql", params, HttpMethod.GET, new Request.Callback() {
                public void onCompleted(Response response) {
                    Log.i(TAG, "Result: " + response.toString());

                    try {
                        GraphObject graphObject = response.getGraphObject();
                        JSONObject jsonObject = graphObject.getInnerJSONObject();

                        Log.d("data", jsonObject.toString());
                        JSONArray array = jsonObject.getJSONArray("data");

                        System.out.println("länge array" + array.length());

                        for (int i = 0; i < array.length(); i++) { //

                            JSONObject friend = array.getJSONObject(i);

                            Log.d("uid", friend.getString("uid"));
                            Log.d("name", friend.getString("name"));

                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            });
            Request.executeBatchAsync(request);
        }
    });
    return view;
}

}

我也想得到我朋友的所有签到但数据是空的 如果有人可以帮助我,我会很高兴

LogCat的输出:

{ "data": []}

1 个答案:

答案 0 :(得分:2)

从Facebook API v2.0开始,朋友列表(/我/朋友和等效的FQL)会返回用户使用您的应用程序的朋友。此限制也适用于处于v1.0模式的应用程序。

如果您希望获取标记操作的朋友:https://developers.facebook.com/docs/graph-api/reference/v2.0/user/taggable_friends

如果您想邀请朋友邀请参加游戏:https://developers.facebook.com/docs/graph-api/reference/v2.0/user/invitable_friends

干杯!