2013-04-03 41 views
1

所以,這裏是我的FQL查詢檢索地點爲用戶事件:FQL查詢iOS中的事件不工作

NSString* fql1 = [NSString stringWithFormat: 
         @"SELECT venue from event WHERE eid in (SELECT eid FROM event_member WHERE uid = me())"]; 
    NSString* fql2 = [NSString stringWithFormat: 
         @"SELECT name FROM page WHERE page_id IN (SELECT venue.id FROM #event_info)"]; 
    NSString* fqlStr = [NSString stringWithFormat: 
        @"{\"event_info\":\"%@\",\"event_venue\":\"%@\"}",fql1,fql2]; 
    NSDictionary* params = [NSDictionary dictionaryWithObject:fqlStr forKey:@"queries"]; 

    FBRequest *fql = [FBRequest requestWithGraphPath:@"fql.query" parameters:params HTTPMethod:@"POST"]; 

    [fql startWithCompletionHandler:^(FBRequestConnection *connection, 
             id result, 
             NSError *error) { 
     if (result) { 
      NSLog(@"result:%@", result); 
     } 
     if (error) { 
      NSLog(@"error:%@", error); 
     } 
    }]; 

查詢本身是好的,我試圖在圖形API瀏覽器。但我得到這個錯誤:

error:Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x1f01da20 {com.facebook.sdk:HTTPStatusCode=403, com.facebook.sdk:ParsedJSONResponseKey={ 
    body =  { 
     error =   { 
      code = 240; 
      message = "(#240) Requires a valid user to be specified (either via the session or via the API parameter for specifying the user."; 
      type = OAuthException; 
     }; 
    }; 
    code = 403; 
}, com.facebook.sdk:ErrorSessionKey=<PFReceptionist: 0xb2426b0>} 

我做錯了什麼?這不是我對會話的第一個查詢,我要求提供user_events權限和事件工作正常的簡單非FQL查詢。

回答

1

下面是它的樣子。糾正我錯誤的情況下。

NSString *query = 
@"{" 
@"'event_info':'SELECT eid, venue, name, start_time, end_time, creator, host, attending_count from event WHERE eid in (SELECT eid FROM event_member WHERE uid = me())'," 
@"'event_venue':'SELECT name, location, page_id FROM page WHERE page_id IN (SELECT venue.id FROM #event_info)'," 
@"}"; 
NSDictionary *queryParam = [NSDictionary dictionaryWithObjectsAndKeys: 
          query, @"q", nil]; 

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

     NSArray* data = [result objectForKey:@"data"]; 
     NSArray* events = [((NSDictionary*) data[0]) objectForKey:@"fql_result_set"]; 
     NSArray* venues = [((NSDictionary*) data[1]) objectForKey:@"fql_result_set"]; 

     NSLog(@"Result: %@", result); 
    }   
}