gpt4 book ai didi

iphone - 从 iOS 应用程序选择并发布到 Facebook 好友的留言墙上

转载 作者:行者123 更新时间:2023-11-29 04:31:52 24 4
gpt4 key购买 nike

我正在应用程序中使用下面的 Facebook Hackbook 示例代码。方法 getFriendsCallAPIDialogFeed 表示(在评论中)该方法“获取用户的 friend ,允许他们选择一个并在他们的墙上发布”

    /*
* 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; 行中,它调用下面的请求方法,然后调用 kAPIFriendsForDialogFeed

我遇到的问题是它随机选择用户的 friend 。我需要用户能够选择他们选择的 friend 。

感谢您的帮助

- (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;
}

最佳答案

使用resultData填充表格,然后将发布代码移动到didSelectRowAtIndexPath中。

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

这个问题告诉您如何发布到 friend 的墙上:Facebook API: Post on friend wall

关于iphone - 从 iOS 应用程序选择并发布到 Facebook 好友的留言墙上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11632583/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com