繁体   English   中英

iOS SDK中的Facebook FQL多重查询

[英]Facebook FQL multiquery in iOS SDK

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

// 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/

如果你想做一个Multiquery而不是一个查询,它看起来像:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM