位置情報ツイートは2タイプ。
- 緯度・経度 (lat, long パラメータ)
- Twitterが管理する場所データベースのエントリ (place_id パラメータ)
緯度・経度
lat パラメータに緯度、long パラメータに経度を指定する。
http://api.twitter.com/1/statuses/update.json?status=hello&lat=37.76893497&long=-122.42284884
のようにすれば緯度経度による位置情報付きのツイートができる (実際には HTTP GET ではなく HTTP POST で)。
Twitterが管理する場所データベースのエントリ
https://api.twitter.com/1/geo/reverse_geocode.json?lat=37.76893497&long=-122.42284884
にて result/places/id を取得して
http://api.twitter.com/1/statuses/update.json?status=hello&place_id=2b6ff8c22edd9576
のようにしてツイートするときに place_id にセットする (実際には HTTP GET ではなく HTTP POST で)。
参考資料
- Twitter API ポケットリファレンス (Book477414732X - MemoWiki) ← 日本語で Twitter API を解説している良書。
- Geo Developer Guidelines | Twitter Developers
- POST statuses/update | Twitter Developers
- GET geo/reverse_geocode | Twitter Developers
- GET geo/search | Twitter Developers
- GET geo/similar_places | Twitter Developers
- POST geo/place | Twitter Developers
tags: twitter
Posted by NI-Lab. (@nilab)