私は現在、ランダムなFacebookの友達を選び、彼らの壁に投稿する次のコードを持っています。すべての友達から選択して(ランダムな友達を選択するのではなく)、彼らのウォールに投稿できるようにしたいと思います。誰かが次のコードで私を助けることができればそれは素晴らしいでしょう:)
case gkAPIFriendsForDialogFeed:
{
NSArray *resultData = [result objectForKey: @"data"];
// Check that the user has friends
if ([resultData count] > 0) {
// Pick a random friend to post the feed to
int randomNumber = arc4random() % [resultData count];
[self apiDialogFeedFriend:
[[resultData objectAtIndex: randomNumber] objectForKey: @"id"]];
} else {
[self showMessage:@"You do not have any friends to post to."];
}
break;
}
このコードはすべての友達を選択しますが、ウォールに投稿せず、代わりに通知を送信します。
case gkAPIGetAppUsersFriendsUsing:
{
NSMutableArray *friendsWithApp = [[NSMutableArray alloc] initWithCapacity:1];
// Many results
if ([result isKindOfClass:[NSArray class]]) {
[friendsWithApp addObjectsFromArray:result];
} else if ([result isKindOfClass:[NSDecimalNumber class]]) {
[friendsWithApp addObject: [result stringValue]];
}
if ([friendsWithApp count] > 0) {
[self apiDialogRequestsSendToUsers:friendsWithApp];
} else {
[self showMessage:@"None of your friends are using Whatto."];
}
[friendsWithApp release];
break;
}