twitter-update
末尾のソースを twitter-update.l の名前で保存して、site-lispに配置。その後.xyzzyに次のように記述してください。
(require "twitter-update") (global-set-key '(#\C-c #\t) 'twitter-update) (setf *twitter-user* "YOUR ID") (setf *twitter-password* "YOUR PASSWORD")
C-c tからtwitterの更新ができるようになります。
なおxml-http-requestに依存します。あらかじめnetinstallerなどから入れておいてください。お手軽に非同期HTTP通信できる、ありがたいライブラリです。
- ステータスバーへの結果表示で日本語が化ける
- JSONの日本語をアンエスケープしていません。xmlで受け取ってxml-parser-modokiにかければよいのですが、オマケ的な部分なので割愛します。
- キーが衝突する
- tDiary-modeあたりとかぶっているようです。適宜修正してご使用下さい。
# キー配置の伝統とかよくわからないのだけど、これでいいのだろうか。 - パスワードが平文
- どうしましょう?
;; twitter-update.l (require "xml-http-request") (defvar *twitter-domain* "twitter.com") (defvar *twitter-update-path* "/statuses/update") (defvar *twitter-user* "") (defvar *twitter-password* "") (defun twitter-update (status) (interactive "stwitter status: " :title0 "update twitter status") (or (string-match " " status) (setf status (concat status " "))) (xml-http-request:http-post (concat "http://" *twitter-user* ":" *twitter-password* "@" *twitter-domain* *twitter-update-path* ".json") (concat "status" "=" (si:www-url-encode (map-internal-to-utf-8 status))) :onfailure #'(lambda (transport) (msgbox "twitter-update: 失敗しました")) :oncomplete #'(lambda (transport) (if (string-match "\"text\" *: *\"\\(.*?\\)\"" (xml-http-request:response-text transport)) (message (concat "twitter-update: " (match-string 1))) (message "twitter-update: done")))))