我目前有以下代码选择随机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;
}
答案 0 :(得分:2)
向多个用户发布帖子违反了Facebook平台条款。您应该坚持使用Requests方法,因为这是向多个用户发送消息的正确方法。
答案 1 :(得分:1)
获取随机ID后调用此函数。
并根据您的应用更改参数。
- (void)sendFBPost:(UIButton *)标记
{
NSString *Message = [NSString stringWithFormat:@"-posted via iPhone App"];
NSMutableDictionary *params1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:
Message, @"message", nil];
NSString *post=[[appDelegate.FBFriendListArray objectAtIndex:tag.tag] objectForKey:@"id"];
[[appDelegate facebook] requestWithGraphPath:[NSString stringWithFormat:@"/%@/feed",post] andParams:params1 andHttpMethod:@"POST" andDelegate:self];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message!" message:@"Invitation Send Sucessfully" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
}