0

以下のFacebookHackbookサンプルコードをアプリで使用しています。getFriendsCallAPIDialogFeedメソッドは、(コメントで)このメソッドは「ユーザーの友達を取得し、ユーザーが友達を選んで壁に投稿できるようにする」と述べています。

    /*
 * Helper method to first get the user's friends then
 * pick one friend and post on their wall.
 */
- (void)getFriendsCallAPIDialogFeed {
    // Call the friends API first, then set up for targeted Feed Dialog
    currentAPICall = kAPIFriendsForDialogFeed;
    [self apiGraphFriends];
}

ただし、行の currentAPICall = kAPIFriendsForDialogFeed; 以下のrequestメソッドを呼び出してから、kAPIFriendsForDialogFeedを呼び出します。

私が抱えている問題は、ユーザーの友達をランダムに選ぶことです。代わりに、ユーザーが選択した友達を選択できるようにする必要があります。

助けてくれてありがとう

- (void)request:(FBRequest *)request didLoad:(id)result {
    [self hideActivityIndicator];
    if ([result isKindOfClass:[NSArray class]] && ([result count] > 0)) {
        result = [result objectAtIndex:0];
    }
    switch (currentAPICall) {

        case kAPIFriendsForDialogFeed:
        {
            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 kAPIGetAppUsersFriendsUsing:
    {
        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

1 に答える 1

1

を使用しresultDataてテーブルにデータを入力し、投稿コードをに移動しますdidSelectRowAtIndexPath

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self apiDialogFeedFriend: 
        [[resultData objectAtIndex: indexPath.row] objectForKey: @"id"]];
}

このSOの質問は、友達の壁に投稿する方法を示しています。Facebook API:友達の壁に投稿する

于 2012-07-24T14:21:58.103 に答える