您可以看看與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];
}