Facebook Graph Api用户对象的位置连接在ios sdk中未正确响应?
我正在尝试检索帖子、状态和照片,其中用户已被标记在某个位置,使用用户连接中的位置。问题是,虽然在Graph Api Explorer中使用适当的权限并获得所需的结果,但在我的应用程序中不会发生同样的情况。响应仅返回缺少位置键的用户id。我使用的代码如下所示: 有关权限:Facebook Graph Api用户对象的位置连接在ios sdk中未正确响应?,ios,objective-c,facebook,facebook-graph-api,facebook-ios-sdk,Ios,Objective C,Facebook,Facebook Graph Api,Facebook Ios Sdk,我正在尝试检索帖子、状态和照片,其中用户已被标记在某个位置,使用用户连接中的位置。问题是,虽然在Graph Api Explorer中使用适当的权限并获得所需的结果,但在我的应用程序中不会发生同样的情况。响应仅返回缺少位置键的用户id。我使用的代码如下所示: 有关权限: NSArray *permissions = [[NSArray alloc] initWithObjects:@"friends_status",@"friends_photos",nil]; if (!FBSession.
NSArray *permissions = [[NSArray alloc] initWithObjects:@"friends_status",@"friends_photos",nil];
if (!FBSession.activeSession.isOpen) {
// if the session is closed, then we open it here, and establish a handler for state changes
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
} else if (session.isOpen) {
[self pickFriendsButtonClick:sender];
}
}];
return;
}
要检索数据,请执行以下操作:
for (int i = 0; i < [selectedFbFriends count]; i++) {
NSString *path = [NSString stringWithFormat:@"me/friends/%@?fields=locations",selectedFbFriends[i]];
FBRequest *friendRequest = [FBRequest requestForGraphPath:path];
[friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id<FBGraphObject> result, NSError *error) {
NSLog(@"%@",result[@"data"]);
}
for(int i=0;i<[selectedFbFriends count];i++){
NSString*路径=[NSString stringWithFormat:@“我/朋友/%@?字段=位置”,选择FBFRIENDS[i]];
FBRequest*friendRequest=[FBRequestForGraphPath:path];
[friendRequest startWithCompletionHandler:^(FBRequestConnection*连接,id结果,NSError*错误){
NSLog(@“%@”,结果[@“数据”);
}
结果与图API管理器中使用相同的路径不一样。我只得到用户ID。我的头会爆裂,因为我找不到什么是错误的,而且权限似乎是合适的。任何帮助都会得到很多赞赏。()
>P>似乎函数没有考虑参数作为路径的一部分。你可以使用。这:
- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
andParams:(NSMutableDictionary *)params
andDelegate:(id <FBRequestDelegate>)delegate;
仔细检查你在graph api explorer和你的应用程序中是否使用了相同的好友id。对我来说效果很好。我只为一些在个人资料中没有任何位置的朋友获取了用户id。不幸的是,我使用了相同的id。只有在应用程序中,响应会错过位置键…现在你告诉我它对你来说很有效…谢谢请打印“路径”的值variable@Vame
2013-07-08 19:23:27.542 FriendSample[594:c07]me/friends/204500396?fields=locations
@Vame copy将其粘贴到graph api explorer我得到了正确的结果虽然使用上面的函数我无法清楚地理解如何实现它,但您给了我一个很好的起点。我使用了下面的函数,它似乎正在工作,并得到了我想要的结果!非常感谢感谢您的时间。NSMutableDictionary*dict=[[NSMutableDictionary alloc]init];[dict setObject:@“locations”forKey:@“fields”];FBRequest*friendRequest=[FBRequest requestWithGraphPath:path参数:dict HTTPMethod:@“GET”;
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:@"locations" forKey:@"fields"];