繁体   English   中英

如何使用iOS上的原生Twitter应用程序打开Twitter推文?

[英]How can I open a Twitter tweet using the native Twitter app on iOS?

Safari可以使用以下格式的链接打开推文:

http://twitter.com/1Direction_X/statuses/197752514391715842

在iOS 5上,Twitter是内置的。 如何使用从我的应用程序调用的本机Twitter应用程序打开上述推文?

这是您从自己的访问其他应用程序的方式。 只需找到要发送访问状态的正确网址即可。 我已经列出了一个应该包含大多数重要列表的列表。 包括状态发现。

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitter://status?id=12345"]];

微博://用户SCREEN_NAME = lorenb

叽叽喳喳://用户ID = 12345

叽叽喳喳://状态ID = 12345

叽叽喳喳://时间表

Twitter的://提到

Twitter的://消息

叽叽喳喳://列表SCREEN_NAME = lorenb&蛞蝓= ABCD

叽叽喳喳://消息帖=你好%20world

Twitter的://留言信息=你好%20world&in_reply_to_status_id = 12345?

叽叽喳喳://搜索查询=%23hashtag

注意:确保用户安装了Twitter或这会导致崩溃非常重要。 所以我建议在尝试将它们发送到twitter之前在if语句中添加它。

[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter://"]];

我会采用以下方法......

NSURL *twitterURL = [NSURL URLWithString:@"fb://profile/<profile_id>"];
if ([[UIApplication sharedApplication] canOpenURL:twitterURL]) {
    [[UIApplication sharedApplication] openURL:twitterURL];
} else {
    WebViewViewController *secondView = [self.storyboard instantiateViewControllerWithIdentifier:@"webinterface"];

    secondView.headerLabel = @"Facebook";
    secondView.webPath = @"https://www.facebook.com/pages/<link_for_page>";

    [self.navigationController pushViewController:secondView animated:YES];
}

WebViewViewController我有webview,我在那里打开链接...

基本上它就像你在iPhone上没有Twitter,它将在WebView中打开...

如果已经回答了这个问题我很抱歉,但是使用主题标签发布消息的架构是:

twitter://post?message=hello%20world%23thisisyourhashtag.  

只需将thisisyourhashtag替换为您希望用户发布的主题标签即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM