2011-02-09 5 views
8

Czy ktoś użył FQL interfejsu API wykresu w systemie iOS? Próbuję uzyskać posty użytkowników z różnych grup Czytałem dokumentację FQL , ale muszę zobaczyć przykład, aby pomóc mi kontynuować? pomóżInterfejs API FQL i Graph w systemie iOS

Odpowiedz

11

Oto przykład:

NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           @"SELECT uid,name FROM user WHERE uid=4", @"query", 
           nil]; 
[facebook requestWithMethodName: @"fql.query" 
         andParams: params 
        andHttpMethod: @"POST" 
         andDelegate: self]; 
8

W ostatnim iOS SDK, metodzie opisanej przez Bertranda nie istnieje. Teraz należy zrobić to w ten sposób:

NSString *query = [NSString stringWithFormat:@"YOUR_QUERY_HERE"]; //begins from SELECT........ 

NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           query, @"q", 
           nil]; 

FBRequest *request = [FBRequest requestWithGraphPath:@"/fql" parameters:params HTTPMethod:@"GET"]; 

[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
    //do your stuff 
}]; 

//or you can do it also with the following class method: 

[FBRequestConnection startWithGraphPath:@"/fql" parameters:params HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, 
              id result, 
              NSError *error) { 
    //do your stuff 
}]; 

Źródło: https://developers.facebook.com/docs/howtos/run-fql-queries-ios-sdk/