Ass*_*f b 4 sql iphone facebook facebook-fql ios
我正在使用FB connect开发iPhone iOS应用程序.
我正在尝试为每个朋友获取大量数据,并且需要多个请求.
我想知道在iOS SDK中是否有使用批量请求的方法?
以及FQL多查询的另一个问题.以下查询仅适用于一位朋友的限制!奇怪的.
SELECT eid FROM event_member WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 2)
它返回错误The operation couldn’t be completed. (facebookErrDomain error 1.)
根据facebook的这个例子它应该一直在工作.
小智 14
您可以使用Facebook iOS SDK进行批量请求,但您需要自己准备JSON请求.这是一个例子:
-(void) prepareMyBatchRequest {
NSString *jsonRequest1 = @"{ \"method\": \"GET\", \"relative_url\": \"me/friends\" }";
NSString *jsonRequest2 = @"{ \"method\": \"GET\", \"relative_url\": \"me/albums\" }";
NSString *jsonRequestsArray = [NSString stringWithFormat:@"[ %@, %@ ]", jsonRequest1, jsonRequest2];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:jsonRequestsArray forKey:@"batch"];
[facebook requestWithGraphPath:@"me" andParams:params andHttpMethod:@"POST" andDelegate:self];
}
- (void)request:(FBRequest *)request didLoad:(id)result {
NSArray *allResponses = result;
for ( int i=0; i < [allResponses count]; i++ ) {
NSDictionary *response = [allResponses objectAtIndex:i];
int httpCode = [[response objectForKey:@"code"] intValue];
NSString *jsonResponse = [response objectForKey:@"body"];
if ( httpCode != 200 ) {
NSLog( @"Facebook request error: code: %d message: %@", httpCode, jsonResponse );
} else {
NSLog( @"Facebook response: %@", jsonResponse );
}
}
}
Run Code Online (Sandbox Code Playgroud)
关于你的其他问题,我不知道(尝试在不同的帖子中提出其他问题,以便更容易跟进).
| 归档时间: |
|
| 查看次数: |
3084 次 |
| 最近记录: |