简体   繁体   English

Facebook Graph Api的位置连接用户对象在ios-sdk中无法正确响应?

[英]Locations Connections of Facebook Graph Api User object not responding properly in ios-sdk?

I am trying to retrieve Posts, statuses, and photos in which a user has been tagged at a location, using the locations in user connections. 我正在尝试使用用户连接中的位置来检索已在某个位置标记了用户的帖子,状态和照片。 The problem is that while using the proper permissions and getting the demanded results in Graph Api Explorer the same does not happen in my app. 问题是,使用适当的权限并在Graph Api Explorer中获得所需的结果时,在我的应用程序中不会发生相同的情况。 The response only returns with the user id missing the location key. 仅在用户ID缺少位置键的情况下返回响应。 The code i use is the following: 我使用的代码如下:

For permissions: 权限:

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

To retrieve data: 要检索数据:

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"]);
}

The result is not the same as using the same path in Graph Api Explorer. 结果与在Graph Api Explorer中使用相同的路径不同。 I only get the user id. 我只得到用户ID。 My head is gonna burst because i can not find what is wrong and the permission seem to be proper ones. 我的头会爆裂,因为我找不到问题所在,而且许可似乎是适当的。 Any help out there would be much appreciated. 任何帮助将不胜感激。 :) :)

Seems like that function doesn't consider the parameters as a part of the path. 似乎该函数并未将参数视为路径的一部分。 You can use this: 您可以使用此:

- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
               andParams:(NSMutableDictionary *)params
               andDelegate:(id <FBRequestDelegate>)delegate;

source: https://developers.facebook.com/docs/reference/iossdk/request/ 来源: https://developers.facebook.com/docs/reference/iossdk/request/ : https://developers.facebook.com/docs/reference/iossdk/request/

where params will be: 参数将在哪里:

NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:@"locations" forKey:@"fields"];

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

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