-1

我正在尝试这段代码,但我遇到了问题,问题是它只返回单身朋友或注册朋友

代码 :

new Request(
                FacebookVariables.fbSession,
                "/me/friends",
                null,
                HttpMethod.GET,
                new Request.Callback() {
                    public void onCompleted(Response response) {
                        /* handle the result */
                        System.out.println("Friends Data "+response);
                    }
                }
            ).executeAsync();

FacebookVariables.fbSession,是我的自定义变量

4

1 回答 1

0
 private void getFriendList() {
        FRIEND_LIST = new ArrayList<entProductFeedItemsComments>();//array list of class
        String fqlQuery = "SELECT name,uid,pic  FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY name";
        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) {

                GraphObject graphObject = response.getGraphObject();
                if (graphObject != null) {
                    if (graphObject.getProperty("data") != null) {
                        try {
                            String _arry = graphObject.getProperty("data").toString();
                            JSONArray _jsonArray = new JSONArray(_arry);
                            if (_jsonArray.length() == 0) {
                                TV_NO_RECORD.setVisibility(View.VISIBLE);
                            } else {
                                TV_NO_RECORD.setVisibility(View.GONE);
                                for (int i = 0; i < _jsonArray.length(); i++) {
                                    JSONObject _jsonObject = _jsonArray.getJSONObject(i);

                                    //fill up your data here 
                                    entProductFeedItemsComments _friendList = new entProductFeedItemsComments(getApplicationContext());
                                    _friendList.setUSER_NAME(_jsonObject.getString("name"));
                                    _friendList.setUSER_FRIEND_ID(_jsonObject.getString("uid"));
                                    _friendList.setPROFILE_PICTURE_PATH(_jsonObject.getString("pic"));
                                    FRIEND_LIST.add(_friendList);
                                }
                                //Set up your adpter here 

                                PROGRESSBAR.setVisibility(View.GONE);
                            }
                        } catch (JSONException ex) {
                            if (ex != null) {
                                Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
                            }
                        }
                    }
                }
            }
        });
        Request.executeBatchAsync(_request);
        PROGRESSBAR.setVisibility(View.VISIBLE);
    }

试试这个,让我知道结果!

于 2014-08-11T06:44:49.517 回答