Twitter for Mac supports Twitter for iPhone protocol handlers

I don't know if there's an official announcement or documentation on it but I realized yesterday, while making Tweaky, that Twitter for Mac supports the same protocol handlers as Twitter for iPhone. The only thing you have to change is the tweetie:// protocol to twitter://.

Check out the protocol reference here.

I use /user and /post protocol handlers in Tweaky to display my tweets and compose a tweet, respectively (e.g., click twitter://user?screen_name=aral to view my timeline in Twitter for Mac).

Note: all arguments to the protocol handlers must be URL encoded and doing that is not as straightforward as it should be with Cocoa. Simon Woodside has a little snippet that does the trick:

NSString * encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
   NULL,
   (CFStringRef)unencodedString,
   NULL,
   (CFStringRef)@"!*'();:@&=+$,/?%#[]",
   kCFStringEncodingUTF8 );

Enjoy!

Comments