2

嗨,我正在尝试在我的 android 应用程序中获取 facebook 用户数据。这是我请求用户信息的方法:

//Requests the user's info
private void makeMeRequest(final Session session){
    //Request request = Request.newMeRequest(session, new Request.GraphUserCallback(){
    Request request = Request.newGraphPathRequest(session, "me/feed", new Request.Callback(){

    @Override
    //public void onCompleted(GraphUser user, Response response){
    public void onCompleted(Response response){
        if(session == Session.getActiveSession()){
          if(user != null){
            GraphObjectList<GraphObject> test =  response.getGraphObjectList();
            //JSONArray test2 = test.getInnerJSONArray();
          }
          if(response.getError() != null){

          }
        }
     });
     request.executeAsync();
}

这是我在 LogCat 中得到的响应:

03-15 21:52:54.650: D/FacebookSDK.Response(324): Response
03-15 21:52:54.650: D/FacebookSDK.Response(324):   Id: 3
03-15 21:52:54.650: D/FacebookSDK.Response(324):   Size: 12042
03-15 21:52:54.650: D/FacebookSDK.Response(324):   Responses:
03-15 21:52:54.650: D/FacebookSDK.Response(324): [{Response:  responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"data":[{"id":"1151520669_10200669350793462","story":"Ameya Savale and Justin Liang are now friends.","status_type":"approved_friend","privacy":{"value":""},"story_tags":{"17":[{"length":12,"id":"1835928976","type":"user","offset":17,"name":"Justin Liang"}],"0":[{"length":12,"id":"1151520669","type":"user","offset":0,"name":"Ameya Savale"}]},"from":{"id":"1151520669","name":"Ameya Savale"},"created_time":"2013-03-15T05:25:20+0000","type":"status","updated_time":"2013-03-15T05:25:20+0000","comments":{"count":0},"actions":[{"link":"http:\/\/www.facebook.com\/1151520669\/posts\/10200669350793462","name":"Comment"},{"link":"http:\/\/www.facebook.com\/1151520669\/posts\/10200669350793462","name":"Like"}]},{"id":"1151520669_10200664042340754","story":"\"that was sick!\" on Akshay Savale's link.","application":{"id":"2309869772","name":"Links"},"privacy":{"value":""},"story_tags":{"20":[{"length":13,"id":"100001055405131","type":"user","offset":20,"name":"Akshay Savale"}]},"from":{"id":"1151520669","name":"Ameya Savale"},"created_time":"2013-03-14T03:54:34+0000","type":"status","updated_time":"2013-03-14T03:54:34+0000","comments":{"count":0}},{"id":"1151520669_10200655210559965","story":"\"time to beat it\" on Salman J Khan's status.","privacy":{"value":""},"story_tags":{"21":[{"length":13,"id":"1036381196","type":"user","offset":21,"name":"Salman J Khan"}]},"from":{"id":"1151520669","name":"Ameya Savale"},"created_time":"2013-03-12T16:53:42+0000","type":"status","updated_time":"2013-03-12T16:53:42+0000","comments":{"count":0}},{"id":"1151520669_10200649624700322","story":"Ameya Savale was invited to UCSB Mastaani by Sharan Ghai.","privacy":{"value":""},"story_tags":{"45":[{"length":11,"id":"500372905","type":"user","offset":45,"name":"Sharan Ghai"}],"0":[{"length":12,"id":"1151520669","type":"user","offset":0,"name":"Ameya Savale"}]},"from":{"id":"1151520669","name":"Ameya Savale"},"created_time":"2013-03-11T22:13:13+0000","type":"status","updated_time":"2013-03-11T22:13:13+0000","comments":{"count":0}},{"id":"1151520669_10200644523212788","story":"\"that was awesome\" on Starrz Dance's link.","privacy":{"value":""},"story_tags":{"22":[{"length":12,"id":"100001846352664","type":"user","offset":22,"name":"Starrz Dance"}]},"from":{"id":"1151520669","name":"Ameya Savale"},"created_time":"2013-03-11T00:48:14+0000","type":"status","updated_time":"2013-03-11T00:48:14+0000","comments":{"count":0}},{"to":{"data":[{"id":"197122410301288","version":1,"name":"Late"}]},"icon":"https:\/\/fbstatic-a.akamaihd.net\/rsrc.php\/v2\/yj\/r\/v2OnaTyTQZE.gif","link":"http:\/\/www.youtube.com\/watch?v=b7YnxTa-y3g%2F","privacy":{"value":""},"from":{"id":"1151520669","name":"Ameya Savale"},"type":"video","updated_time":"2013-03-10T01:58:29+0000","picture":"https:\/\/fbexternal-a.akamaihd.net\/safe_image.php?d=AQCZDACZ9Lqjh87R&w=130&h=130&url=http%3A%2F%2Fi3.ytimg.com%2Fvi%2Fb7YnxTa-y3g%2Fmqdefault.jpg","message":"www.youtube.com\/watch?v=b7YnxTa-y3g\/\n\nlol","id":"1151520669_607003655979826","source":"http:\/\/www.youtube.com\/v\/b7YnxTa-y3g?version=3&autohide=1&autoplay=1","description":"Wild animals eat fast food all the time. A rabbit is fast, an Impala is fast, and zebra run fast too.","name":"What If.......Wild Animals Ate Fast Food","created_time":"2013-03-10T01:58:29+0000","comments":{"count":0},"actions":[{"link":"http:\/\/www.facebook.com\/1151520669\/posts\/607003655979826","name":"Comment"},{"link":"http:\/\/www.facebook.com\/1151520669\/posts\/607003655979826","name":"Like"}]},{"picture":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-prn1\/50233_36022998530_1525_q.jpg","id":"1151520669_10200631849415951","icon":"https:\/\/fbstatic-a.akamaihd.net\/rsrc.php\/v2\/yN\/r\/xC785tTCIQO.gif","story":"Ameya Savale likes Zodo's - Bowling & Beyond.","application":{"id":"2530096808","name":"Pages"},"link":"http:\/\/www.facebook.com\/ZodosBowling?ref=stream","privacy":
03-15 21:53:33.540: D/dalvikvm(284): GC_EXPLICIT freed 7969 objects / 423976 bytes in 146ms

所以我很确定我会收到回复,但是当我在我的方法中取消注释该行时,我会得到一个NullPointerException. 为什么它给我这个?我也打印了我的会话信息,这是输出:

03-15 20:53:20.186: I/SESSION(321): {Session state:OPENED, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[read_stream, user_birthday, user_likes, user_status, basic_info]}, appId:222555791218743}

这个错误是因为ACCESS_TOKEN_REMOVED零件吗?如果是我怎么能正确登录?

谢谢

4

0 回答 0