2012-10-05 58 views
1

我試圖得到一個用戶名,pic_square,並使用FQL聲明狀態對象:IOS Facebook的API的用戶狀態返回NULL

它使用圖形API瀏覽器的偉大工程。下面是結果:

{ 
    "data": [ 
    { 
     "uid": 657asdf, 
     "name": "Name1", 
     "pic_square": "http://profile.ak.fbcdn.net/hprofile-ak-snc7/371062_657477736_1asd.jpg", 
     "status": { 
     "message": "who want's to bring me a burrito?", 
     "time": 1349381334, 
     "status_id": "1015110984sadf", 
     "comment_count": 0 
     } 
    }, 
    { 
     "uid": 123asdf, 
     "name": "name2", 
     "pic_square": "http://profile.ak.fbcdn.net/hprofile-ak-snc6/275748_607345433_91234.jpg", 
     "status": { 
     "message": "my excitement for tonight on a scale of 1-10 just went from a 15 to a 3 pretty quick", 
     "time": 1349386828, 
     "status_id": "1015216195asdf", 
     "comment_count": 0 
     } 
    }, 

但在Xcode我得到以下結果,注意狀態<null>

data =  (
       { 
      name = "Name1"; 
      "pic_square" = "http://profile.ak.fbcdn.net/hprofile-ak-ash4/371941_803145_672321642_q.jpg"; 
      status = "<null>"; 
      uid = 801asdf; 
     }, 
       { 
      name = "Name2"; 
      "pic_square" = "http://profile.ak.fbcdn.net/hprofile-ak-ash4/276004_2403715_8811asdf.jpg"; 
      status = "<null>"; 
      uid = 240asdf; 
     }, 

下面是代碼,我移植from here

NSString *query = 
    @"SELECT uid, name, pic_square, status FROM user WHERE (uid IN " 
    @"(SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 1055)) ORDER BY status.time"; 

    NSDictionary *queryParam = 
    [NSDictionary dictionaryWithObjectsAndKeys:query, @"q", nil]; 
    // Make the API request that uses FQL 

    [FBRequestConnection startWithGraphPath:@"/fql" 
           parameters:queryParam 
           HTTPMethod:@"GET" 
          completionHandler:^(FBRequestConnection *connection, 
               id result, 
               NSError *error) { 
           if (error) { 
            NSLog(@"Error: %@", [error localizedDescription]); 
           } else { 
            NSLog(@"Result: %@", result); 

           } 
          }]; 

這是IOS Facebook API FBRequestConnection方法的限制嗎?有其他方法嗎?我確定我不是唯一一個試圖在一個FQL查詢中獲得用戶名和狀態的人。

回答

0

這是用戶錯誤。我沒有設置適當的權限來獲取狀態。我必須在權限數組中包含「frends_status」。

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI { 
    NSArray *permissions = [[NSArray alloc] initWithObjects: 
          @"user_likes", 
          @"read_stream", 
          @"friends_status", 
          nil];