gpt4 book ai didi

iOS:如何从我的应用程序中打开 Facebook 应用程序中的特定帖子?

转载 作者:可可西里 更新时间:2023-11-01 06:09:47 26 4
gpt4 key购买 nike

当 Safari 打开 URL 时,我可以轻松链接到 Facebook 上的特定帖子,但我还没有找到在 Facebook 应用程序中打开该帖子的方法。在用户必须单击“更多帖子”之前,Facebook 应用程序仅显示大约三个最近的帖子。因此,要找到他们感兴趣的帖子有点困难。现在这是我的代码,它允许用户链接到 Safari 中的确切帖子,但如果安装了 Facebook 应用程序则不能。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *postID = [[parsedPosts objectAtIndex:[indexPath indexAtPosition:1]] objectForKey:@"post_id"];
NSArray *idParts = [postID componentsSeparatedByString:@"_"];
UIApplication *sharedApp = [UIApplication sharedApplication];
NSURL *faceBookURL = [NSURL URLWithString:[NSString stringWithFormat:@"fb://profile/%@", [idParts objectAtIndex:0]]];
if([sharedApp canOpenURL:faceBookURL]){
[sharedApp openURL:faceBookURL];
} else {
NSURL *safariURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://m.facebook.com/story.php?story_fbid=%@&id=%@", [idParts objectAtIndex:1], [idParts objectAtIndex:0]]];
[sharedApp openURL:safariURL];
}
}

一个无效的 URL,但应该:fb://post/123456789_123456789

最佳答案

如果还是这样的话。

首先,您需要按字符“_”拆分您的帖子 ID。

然后使用路径:fb://profile/{id} 其中 {id} 将等于从拆分中获得的数组的第二部分。这对我有用。

澄清:ID 123456_789789 将成为一个数组 = [123456,789789] 然后你的 url 将看起来像这样 fb://profile/789789

关于iOS:如何从我的应用程序中打开 Facebook 应用程序中的特定帖子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19745818/

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