1

因此,这是我的 FQL 查询,用于检索用户事件的场所:

    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);
        }
    }];

查询本身很好,我在 Graph API Explorer 中尝试过。但我收到了这个错误:

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 事件查询工作正常。

4

1 回答 1

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);
    }        
}
于 2013-04-18T17:01:36.600 回答