IOS Facebook API用户状态返回NULL

时间:2012-10-05 03:51:21

标签: objective-c ios facebook-fql status

我试图使用FQL语句获取用户名,pic_square和状态对象:

使用Graph API Explorer可以很好地工作。结果如下:

{
  "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查询中获取用户名和状态的人。

1 个答案:

答案 0 :(得分:0)

这是用户错误。我没有设置适当的权限来获取状态。我必须包括&#34; frends_status&#34;到权限数组。

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