NSSharingService を使用すると、簡単に Twitter にツイートを投稿できるようです。
MacRuby Nightly をインストール
Xcode 4.3.3 から Xcode の Framework のサーチパスが変わったらしく、MacRuby アプリケーションを作成しようとするとビルドエラーになります。
https://github.com/MacRuby/MacRuby/issues/107
そこで、最新の MacRuby Nightly インストールします。
https://macruby.macosforge.org/files/nightlies/
Xcode で NSSharingService を使用するアプリケーションを作成
MacRuby Applications というXcode のテンプレートを用いて、アプリケーションのプロジェクトを作成します。
その後、以下のようなコードを AppDelegate.rb
に記述すると簡単な通知が行えます
AppDelegate.rb
class AppDelegate
attr_accessor :window
def applicationDidFinishLaunching(a_notification)
# Insert code here to initialize your application
serv = NSSharingService.sharingServiceNamed(NSSharingServiceNamePostOnTwitter)
serv.performWithItems(["test tweet"])
end
end
アプリケーションを実行すると、以下のようにメッセージが埋め込まれた状態でツイートするためのウィンドウがポップアップします。