0

私は現在、ランダムな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;
        }
4

2 に答える 2

2

複数のユーザーの壁に投稿することは、Facebookプラットフォームの規約に違反します。複数のユーザーにメッセージを送信する正しい方法であるため、代わりにRequestsメソッドを使用する必要があります。

于 2012-07-23T11:36:47.320 に答える
1

ランダムIDを取得した後にこの関数を呼び出します。

アプリに応じてパラメータを変更します。

-(void)sendFBPost:(UIButton *)tag

{{

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];

}

于 2012-07-23T11:53:03.137 に答える