iOS中的FQL和Graph API

Din*_*ina 8 facebook facebook-fql ios

有没有人在iOS中使用过FQL的图形API?我试图从不同的组中获取用户帖子我已阅读FQL文档但我需要看一个示例来帮助我继续吗?请帮忙

小智 11

这是一个例子:

    NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                @"SELECT uid,name FROM user WHERE uid=4", @"query",
                                nil];
[facebook   requestWithMethodName: @"fql.query"
                         andParams: params
                     andHttpMethod: @"POST"
                       andDelegate: self];
Run Code Online (Sandbox Code Playgroud)


Nat*_* R. 8

在上一个iOS SDK中,Bertrand提到的方法不存在.现在你应该这样做:

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
}];
Run Code Online (Sandbox Code Playgroud)

资料来源:https://developers.facebook.com/docs/howtos/run-fql-queries-ios-sdk/