古い記事
ランダムジャンプ
新しい記事
@tsupo さんより献本いただきました。
ありがとうございました。(ref. [2010-04-14-2])

辻村浩 / Twitter API プログラミング

モバツイやBuzztter、ふぁぼったーなど、Twitterを使ったおもしろいサービスがたくさんあります。
これもTwitterが人気を集めている理由の1つでしょう。
Twitterは、その機能のほとんどをAPI経由で使うことができます。

本書は、公式ドキュメントをもとにそれぞれのAPIの使い方をわかりやすくまとめたリファレンスです。
サンプルコードも紹介していますので、本書があれば、すぐにアイデアを実現できます!

Twitter API ドキュメントの日本語訳でもおなじみの @tsupo さんによる API 本です。
- Twitter API 仕様書(tsupo訳)
http://watcher.moe-nifty.com/memo/docs/twitterAPI.txt

リファレンスも含め一通り目を通しつつ、実際に手を動かして試したりしました。
いじってみたAPIのうち curl やブラウザで試したものをいくつかあげておきます(U=アカウント名、P=パスワード)。

タイムライン関連のAPI:
curl -uU:P -d'count=20&page=1' http://api.twitter.com/1/statuses/home_timeline.json
curl -uU:P -d'count=20&page=1' http://api.twitter.com/1/statuses/retweeted_by_me.json

ツイート関連のAPI:
curl -uU:P -d'status=%E6%9D%B1' http://api.twitter.com/1/statuses/update.xml

ユーザ情報関連のAPI:
curl -uU:P 'http://api.twitter.com/1/users/show.xml?screen_name=yto'
curl -uU:P http://api.twitter.com/1/statuses/friends/2067431.xml
curl -uU:P 'http://api.twitter.com/1/friendships/show.xml?source_screen_name=yto&target_screen_name=apipix'
curl -uU:P http://api.twitter.com/1/friends/ids/yto.xml
curl -uU:P http://api.twitter.com/1/followers/ids/yto.xml

アカウント関連のAPI:
curl -uU:P -d'profile_text_color=880' http://api.twitter.com/1/account/update_profile_colors.xml
curl -uU:P -d'location=Japan' http://api.twitter.com/1/account/update_profile.xml

お気に入り関連のAPI:
curl -uU:P http://api.twitter.com/1/favorites/2067431.xml

検索関連のAPI:
http://search.twitter.com/search.atom?q=chalow
http://search.twitter.com/search.atom?q=chalow&rpp=100
http://search.twitter.com/search.atom?q=chalow&since=2010-04-20
http://search.twitter.com/search.json?q=chalow&callback=f

ストリーミングAPI:
- Twitter のストリーミング API を試す[2010-04-15-2]

その他:
- 認証については別途まとめます。
- 巻末に Twitter API を利用したサービスの開発者のインタビューがあります。