2012-09-11 41 views
0

我在移動應用程序中使用請求對話框。閱讀 https://developers.facebook.com/docs/reference/dialogs/requests/ 我發現Facebook的移動要求對話框 - 過濾用戶

注:過濾器選項是在移動對話框禁用,不會影響組出現的對話框中的用戶。

不幸的是,我只需要顯示朋友的應用程序安裝在一個對話框中,並在其他對話中休息。在仍然使用FB請求對話框的情況下是否有任何合理的方式來過濾這樣的用戶?

回答

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]; 
} 
相關問題