Ios4 iPhone SDK上的自定义图形API请求
是否可以使用FBConnect进行自定义图形API调用 比如说,Ios4 iPhone SDK上的自定义图形API请求,ios4,facebook-graph-api,Ios4,Facebook Graph Api,是否可以使用FBConnect进行自定义图形API调用 比如说, [facebook requestWithGraphPath:@"me" andDelegate:self]; 通过这个电话,我可以看到自己的详细信息 [facebook requestWithGraphPath:@"me/friends" andDelegate:self]; 用这个我可以看到我的朋友 [facebook requestWithGraphPath:@"FRIEND_ID/picture" andDelegat
[facebook requestWithGraphPath:@"me" andDelegate:self];
通过这个电话,我可以看到自己的详细信息
[facebook requestWithGraphPath:@"me/friends" andDelegate:self];
用这个我可以看到我的朋友
[facebook requestWithGraphPath:@"FRIEND_ID/picture" andDelegate:self];
有了这个,我可以看到一张id=friend\u id的朋友的照片
是否有可能在一次调用中进行自定义Graph API调用,以获取我所有facebook好友的id、图片、姓名,例如电子邮件
我遇到的问题是,当我打电话时:
[facebook requestWithGraphPath:@"me/friends" andDelegate:self];
在:
我获取我朋友的ID,然后,在for循环中,我想这样做:
[[self appDelegate].facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/picture",[[party.attendantsDictionary allKeys] objectAtIndex:i]] andDelegate:self];
之后,在
- (void)request:(FBRequest *)request didLoad:(id)result;
我有:
if ([result isKindOfClass:[NSData class]]) {
[party.attendantsPictures addObject:[[UIImage alloc] initWithData:result]];
}
问题是我朋友的照片和名字都混在一起了
有人有解决方案吗?您可以尝试nsrunlop 在我的情况下,我想加载用户名,状态,个人资料图片一次。但是,requestWithGraphPath及其委托didload:result一次只能处理每个请求。所以我所做的是: 1/设置标签号 2/每次请求后,等待请求完成,将标签号增加1 所以在我的按钮动作中
tagNo = 0;
[facebook requestWithGraphPath:graphPathZero // For user's name
andDelegate:detailVC];
while ( tagNo == 0) && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
[facebook requestWithGraphPath:graphPathOne // For user's status
andDelegate:detailVC];
while ( tagNo == 1) && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
[facebook requestWithGraphPath:graphPathTwo // For user's profile picture
andDelegate:detailVC];
while ( tagNo == 2) && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
在代表中
switch (tagNo) {
case 0:
// Do something with result
break;
case 1:
// Do something with result
break;
case 2:
// Do something with result
break;
default:
break;
}
++tagNo;
我可能不会在这里介绍“用结果做点什么”,因为它在stackoverflow的其他地方。这可能不是解决方案,但我发现它是可以接近的。寻求他人的更多贡献;) 嗯,我从未使用过nsrunlop。你能给我一个提示吗?(苹果的文档有点让人困惑…) 在你的情况下,我会这样做:
NSString *fql = @"SELECT name, uid, pic_square, status FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:fql, @"query", nil];
[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"POST" andDelegate:self];
这样,您就可以从用户那里获得所需的一切。Hmmm,我从未使用过nsrunlop。你能给我一个提示吗?(苹果的文档有点混乱…)哇,你的解决方案应该是正确的…我所做的就像请求一样,等待请求完成,然后继续下一个请求
NSString *fql = @"SELECT name, uid, pic_square, status FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:fql, @"query", nil];
[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"POST" andDelegate:self];