0

我在移动应用程序中使用请求对话框。阅读 https://developers.facebook.com/docs/reference/dialogs/requests/ 我发现

注意:过滤器选项在移动对话框中被禁用,并且不会影响出现在对话框中的用户集。

不幸的是,我只需要在一个对话框中显示安装了应用程序的朋友,而在另一个对话框中休息。是否有任何合理的方法可以在仍然使用 FB 请求对话框的同时过滤这样的用户?

4

1 回答 1

1

您可以查看与 SDK 一起打包的 Hackbook 示例应用程序,以向您展示如何执行此操作,但本质上您必须创建一个 API 调用来获取(例如安装了该应用程序的用户)并将其传递给名为“建议”。

- (void)sendRequest:(NSArray *) targeted {
    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"It's your turn, quit slacking.",  @"message",
                               nil];

    // Filter and only show targeted friends
    if (targeted != nil && [targeted count] > 0) {
        NSString *selectIDsStr = [targeted componentsJoinedByString:@","];
        [params setObject:selectIDsStr forKey:@"suggestions"];
    }

    [self.facebook dialog:@"apprequests"
                  andParams:params
                andDelegate:self];
}


- (void) sendToAppUsers {
    FBRequest *appUsersRequest = [[FBRequest alloc]
                                  initWithSession:FBSession.activeSession
                                  restMethod:@"friends.getAppUsers"
                                  parameters:nil
                                  HTTPMethod:@"GET"];
    FBRequestConnection *appUsersConnection = [[FBRequestConnection alloc] init];
    [appUsersConnection
     addRequest:appUsersRequest
     completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
         // Process the results
         NSMutableArray *friendsWithApp = [[NSMutableArray alloc] init];
         // Many results
         if ([result isKindOfClass:[NSArray class]]) {
             [friendsWithApp addObjectsFromArray:result];
         } else if ([result isKindOfClass:[NSDecimalNumber class]]) {
             [friendsWithApp addObject: [result stringValue]];
         }
         // User has friends that pass this filter
         if ([friendsWithApp count] > 0) {
             [self sendRequest:friendsWithApp];
         }
    }];
    [appUsersConnection start];
}
于 2012-10-24T23:07:09.610 回答