iOS SDK 中的 Facebook FQL 多重查询

发布于 2024-11-07 14:13:59 字数 333 浏览 0 评论 0原文

我正在寻找一些有关如何通过 iOS SDK 向 Facebook 发送多查询 fql 请求的文档或示例代码。 我找到了一些较旧的样本,但它们对我不起作用。 我已经用查询填充了 NSDictionary ,并尝试通过以下方式发送请求 [[FBRequest requestWithDelegate:self] call:@"facebook.fql.multiquery" params:params];,如我读过的示例中所述,但我收到“无法识别的选择器发送到类”错误,我也无法在 FBRequest.h 中找到“requestWithDelegate”方法。它已被弃用吗? 对此的一些帮助将非常感激!

I am looking for some documentation or sample code on how to send multiquery fql requests to Facebook via iOS SDK.
I found some older samples but they doesnt work for me.
I have populated an NSDictionary with the queries and I try to send the request via
[[FBRequest requestWithDelegate:self] call:@"facebook.fql.multiquery" params:params];, as stated in the samples I have read, but I get an "unrecognized selector sent to class" error and I cant find the "requestWithDelegate" method in FBRequest.h either. Is it deprecated?
Some help on this would be very appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梅窗月明清似水 2024-11-14 14:13:59
// Construct your FQL Query 
NSString* fql = [NSString stringWithFormat:@"SELECT uid, name, hometown_location from user where uid IN (SELECT uid2 FROM friend WHERE uid1=%lld) and hometown_location != '' ORDER BY rand() limit 4", facebookId];

// Create a params dictionary
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:fql forKey:@"query"];

// Make the request 
[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"GET" andDelegate:self];

委托 FBRequestDelegate 将随响应一起调用。根据您的需要,您将执行以下操作:

- (void)request:(FBRequest*)request didLoad:(id)result {
    NSLog(@"didLoad() received result: %@", result);
}

Facebook 对象的创建方式如下:

Facebook * facebook = [[Facebook alloc] initWithAppId:kAppID];

有关如何设置的更多信息可以在此处找到:
https://developers.facebook.com/docs/guides/mobile/

并且取决于对于 FQL 查询,您需要获得用户的权限。请参阅此处的权限列表:
https://developers.facebook.com/docs/authentication/permissions/

有这里还有一个 FQL 查询的测试控制台:
https://developers.facebook.com/docs/reference/rest/fql。 query/

如果你想执行多重查询而不是单个查询,它看起来像:

NSString* fql1 = [NSString stringWithFormat:
    @"select uid2 from friend where uid1 == %lld order by rand() limit 10", facebookId];
NSString* fql2 = [NSString stringWithFormat:
    @"select uid, name from user where uid in (select uid2 from #queryID)"];
NSString* fql3 = [NSString stringWithFormat:
    @"select uid, status_id, message from status where uid in (select uid from #queryName) limit 1"];
NSString* fql = [NSString stringWithFormat:
    @"{\"queryID\":\"%@\",\"queryName\":\"%@\",\"queryStatus\":\"%@\"}",fql1,fql2,fql3];

NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"queries"];   

[facebook call:@"fql.multiquery" params:params];
// Construct your FQL Query 
NSString* fql = [NSString stringWithFormat:@"SELECT uid, name, hometown_location from user where uid IN (SELECT uid2 FROM friend WHERE uid1=%lld) and hometown_location != '' ORDER BY rand() limit 4", facebookId];

// Create a params dictionary
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:fql forKey:@"query"];

// Make the request 
[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"GET" andDelegate:self];

The the delegate FBRequestDelegate will be call with the response. Depending on your needs, you'll do something like:

- (void)request:(FBRequest*)request didLoad:(id)result {
    NSLog(@"didLoad() received result: %@", result);
}

The facebook object is created like:

Facebook * facebook = [[Facebook alloc] initWithAppId:kAppID];

More info on how to set this up can be found here:
https://developers.facebook.com/docs/guides/mobile/

And depending on your FQL query, you will need permissions from the user. See the list of permissions here:
https://developers.facebook.com/docs/authentication/permissions/

There is also a test console for FQL queries here:
https://developers.facebook.com/docs/reference/rest/fql.query/

And if you want to do an Multiquery instead of a single query, it would look like:

NSString* fql1 = [NSString stringWithFormat:
    @"select uid2 from friend where uid1 == %lld order by rand() limit 10", facebookId];
NSString* fql2 = [NSString stringWithFormat:
    @"select uid, name from user where uid in (select uid2 from #queryID)"];
NSString* fql3 = [NSString stringWithFormat:
    @"select uid, status_id, message from status where uid in (select uid from #queryName) limit 1"];
NSString* fql = [NSString stringWithFormat:
    @"{\"queryID\":\"%@\",\"queryName\":\"%@\",\"queryStatus\":\"%@\"}",fql1,fql2,fql3];

NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"queries"];   

[facebook call:@"fql.multiquery" params:params];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文