2013-04-13 143 views
1

由於某些原因,即使我已經從樣本中幾乎完全複製了此代碼,但似乎無法看到我的朋友的任何信息。我只有幾個朋友使用假帳戶。有人能給我一個什麼可能會出錯的想法嗎?遇到executeMyFriendsRequestAsync問題

Session.openActiveSession(this, true, new Session.StatusCallback() { 
    @Override 
    public void call(Session session, SessionState state, Exception exception) { 
     if (session.isOpened()) { 
     Request.executeMyFriendsRequestAsync(session, new Request.GraphUserListCallback() { 
     @Override 
    public void onCompleted(List<GraphUser> users, Response response) { 
     Log.d("INFO", "on complete"); 
     Log.i("INFO", "" + users.toString()); 

回答

1
final Runnable getFacebookUserInfo = new Runnable() { 
    @Override 
    public void run() { 
     Request.executeMeRequestAsync(facebookConnector.getFacebook() 
       .getSession(), new Request.GraphUserCallback() { 
      @Override 
      public void onCompleted(GraphUser user, Response response) 
      { 
       //... 
      } 
     }); 

     Request.executeMyFriendsRequestAsync(facebookConnector.getFacebook() 
       .getSession(), new Request.GraphUserListCallback() { 
      @Override 
      public void onCompleted(List<GraphUser> users, Response response) { 
       if (users != null) { 
        List<String> friendsList = new ArrayList<String>(); 
        for (GraphUser user : users) { 
         friendsList.add(user.getId()); 
         //... 
        } 
       } 
      } 
     }); 
} 

};

我認爲它很有用。