简体   繁体   中英

How do I open a user's Twitter profile using the Twitter app using a link in Mobile Safari?

It looks like Twitter registers the URI scheme of twitter://, but after playing around with it I can't get it to directly open a user's profile. I've tried:

twitter://username
twitter://user/username
twitter://profile/username

with no luck. I'll need it to work on Android as well.

Thoughts?

I found two URL schemes for twitter tweetie:// and twitter:// :

tweetie:///user?screen_name=jessicaalba
twitter:///user?screen_name=jessicaalba

On this wiki site you can find a lot of other iphone url schemes (including twitter)

Doesn't seem to be official documented anywhere so I wouldn't count on all versions of the Twitter app supporting it but http://groups.google.com/group/twitter-development-talk/browse_thread/thread/92b958b7af002993?pli=1 gives a hint that might be worth a try:

I just found that "twitter:///user?screen_name=tvdw" works as well.

I know you are looking specifically to open it up with the official Twitter app but what if the person doesn't have the app, then the functionality will not work in your app.

Why not just use MGTwitterEngine in this case since it will work for everyone and it will remain in your app?

For those wondering how to test if the scheme executes:

- (BOOL)openURL:(NSString *)url
- (void) clickTwitter {
    if (![self openURL:@"twitter:///user?screen_name=mufumbo"]) {
        if (![self openURL:@"tweetie:///user?screen_name=mufumbo"]) {
            [self openURL:@"http://twitter.com/mufumbo"];   
        }
    }
}

you can include many more and make it a generic loop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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