statuses/updateに付与できる場所情報を検索します。経度と緯度の組み合わせやIPアドレスや名前を設定してリクエストすることで、ステータス更新時に place_idとして使用できる全ての有効な位置情報の一覧を取得します。
Conceptually, a query can be made from the user’s location, retrieve a list of places, have the user validate the location he or she is at, and then send the ID of this location with a call to POST statuses/update.
statuses/updateに付与できる位置情報を探すに際には、このメソッドを使用することを推奨します。 Unlike GET geo/reverse_geocode which provides raw data access, this endpoint can potentially re-order places with regards to the user who is authenticated. This approach is also preferred for interactive place matching with the user.
このメソッドで使用するパラメータの中には、他のパラメータを設定した場合にのみ必須となるものがあります。 例えば、“long”を設定した場合は“lat”も設定しなければならず、逆もまた然りです。認証を実施することが推奨されますが、必須ではありません。
https://api.twitter.com/1.1/geo/search.json
注意: 次のパラメータのうち少なくとも一つは必ず設定しなければなりません: lat, long, ip, query
検索する周辺の経度。値が-90.0 から +90.0 の範囲でないと(北の方角が正)、このパラメータは無視されます。 対応するlongパラメータが設定されていない場合も無視されます。
サンプル値: 37.7821120598956
検索する周辺の緯度。-180.0 から +180.0 の範囲が設定できます(東の方角が正)。この範囲外の場合、 geo_enabledが無効になっている場合、対応するlatパラメータが設定されていない場合、このパラメータは無視されます。
サンプル値: -122.400612831116
地名ベースのクエリを実行することができる自由形式のテキスト文。地名の近くにある位置を検索する場合に最適なパラメータです。クエリをURLエンコードすることを忘れないでください。
サンプル値: Twitter%20HQ
IP アドレス。ユーザーのIDアドレスを基に地理情報を修正する場合に使用されます。
サンプル値: 74.125.19.104
これは取得する場所タイプの最少粒度で、poi, neighborhood, city, admin , countryのうちどれかを使用します。 リクエストでgranularity を設定しなかった場合は、neighborhoodが設定されたと見なされます。
例えば、今パラメータにcityを設定すると、 cityやadminや countryのタイプを持っている場所を検索します。
サンプル値: city
検索する “範囲(region)”のヒント。 単に数字だけを設定した場合、メートル単位の半径として使われます。末尾にft の文字列を付けると、単位をフィートに変更することができます。 設定しなかった場合、0mを設定したと見なされます。 If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).
サンプル値: 5ft
取得する検索結果数のヒント。常にここで設定したmax_resultsと同じ数の結果が取得できるとは限りませんが、その代わり同等数の “(近隣)nearby”の検索結果を取得します。 理想としては、ユーザーに表示したいだけの場所情報数を設定します。
サンプル値: 3
これは検索結果を制限する place_id です。この値を設定すると、指定したplace_id の範囲内の場所のみを検索します。
このパラメータには place_idを設定します。例えば、検索する場所を “San Francisco, CA USA”内にする場合は “5a110d312052166f”のplace_idを設定します。
サンプル値: 247f43d441defc03
このパラメータを使って、指定した通りの住所を表す場所情報を検索します。 こうした良く知られている属性のほかに、固有の属性も用意されてます。カスタム属性を使用することも認められています。 詳細についてはPlace Attributesを参照してください。
サンプル値: 795%20Folsom%20St
これを設定すると、応答には指定した名前のコールバックを持つ JSONP 形式が使われます。
ログインして登録アプリケーションの一覧を参照してください。
GET
https://api.twitter.com/1.1/geo/search.json?query=Toronto
{
"query": {
"params": {
"accuracy": 0,
"autocomplete": false,
"granularity": "neighborhood",
"query": "Toronto",
"trim_place": false
},
"type": "search",
"url": "https://api.twitter.com/1.1/geo/search.json?accuracy=0&query=Toronto&granularity=neighborhood&autocomplete=false&trim_place=false"
},
"result": {
"places": [
{
"attributes": {},
"bounding_box": {
"coordinates": [
[
[
-96.647415,
44.566715
],
[
-96.630435,
44.566715
],
[
-96.630435,
44.578118
],
[
-96.647415,
44.578118
]
]
],
"type": "Polygon"
},
"contained_within": [
{
"attributes": {},
"bounding_box": {
"coordinates": [
[
[
-104.057739,
42.479686
],
[
-96.436472,
42.479686
],
[
-96.436472,
45.945716
],
[
-104.057739,
45.945716
]
]
],
"type": "Polygon"
},
"country": "United States",
"country_code": "US",
"full_name": "South Dakota, US",
"id": "d06e595eb3733f42",
"name": "South Dakota",
"place_type": "admin",
"url": "https://api.twitter.com/1.1/geo/id/d06e595eb3733f42.json"
}
],
"country": "United States",
"country_code": "US",
"full_name": "Toronto, SD",
"id": "3e8542a1e9f82870",
"name": "Toronto",
"place_type": "city",
"url": "https://api.twitter.com/1.1/geo/id/3e8542a1e9f82870.json"
},
{
"attributes": {},
"bounding_box": {
"coordinates": [
[
[
-80.622815,
40.436469
],
[
-80.596567,
40.436469
],
[
-80.596567,
40.482566
],
[
-80.622815,
40.482566
]
]
],
"type": "Polygon"
},
"contained_within": [
{
"attributes": {},
"bounding_box": {
"coordinates": [
[
[
-84.820305,
38.403423
],
[
-80.518454,
38.403423
],
[
-80.518454,
42.327132
],
[
-84.820305,
42.327132
]
]
],
"type": "Polygon"
},
"country": "United States",
"country_code": "US",
"full_name": "Ohio, US",
"id": "de599025180e2ee7",
"name": "Ohio",
"place_type": "admin",
"url": "https://api.twitter.com/1.1/geo/id/de599025180e2ee7.json"
}
],
"country": "United States",
"country_code": "US",
"full_name": "Toronto, OH",
"id": "53d949149e8cd438",
"name": "Toronto",
"place_type": "city",
"url": "https://api.twitter.com/1.1/geo/id/53d949149e8cd438.json"
},
{
"attributes": {},
"bounding_box": {
"coordinates": [
[
[
-79.639128,
43.403221
],
[
-78.90582,
43.403221
],
[
-78.90582,
43.855466
],
[
-79.639128,
43.855466
]
]
],
"type": "Polygon"
},
"contained_within": [
{
"attributes": {},
"bounding_box": {
"coordinates": [
[
[
-95.155919,
41.676329
],
[
-74.339383,
41.676329
],
[
-74.339383,
56.852398
],
[
-95.155919,
56.852398
]
]
],
"type": "Polygon"
},
"country": "Canada",
"country_code": "CA",
"full_name": "Ontario, Canada",
"id": "89b2eb8b2b9847f7",
"name": "Ontario",
"place_type": "admin",
"url": "https://api.twitter.com/1.1/geo/id/89b2eb8b2b9847f7.json"
}
],
"country": "Canada",
"country_code": "CA",
"full_name": "Toronto, Ontario",
"id": "8f9664a8ccd89e5c",
"name": "Toronto",
"place_type": "city",
"url": "https://api.twitter.com/1.1/geo/id/8f9664a8ccd89e5c.json"
},
{
"attributes": {},
"bounding_box": {
"coordinates": [
[
[
-90.867234,
41.898723
],
[
-90.859467,
41.898723
],
[
-90.859467,
41.906811
],
[
-90.867234,
41.906811
]
]
],
"type": "Polygon"
},
"contained_within": [
{
"attributes": {},
"bounding_box": {
"coordinates": [
[
[
-96.639485,
40.375437
],
[
-90.140061,
40.375437
],
[
-90.140061,
43.501196
],
[
-96.639485,
43.501196
]
]
],
"type": "Polygon"
},
"country": "United States",
"country_code": "US",
"full_name": "Iowa, US",
"id": "3cd4c18d3615bbc9",
"name": "Iowa",
"place_type": "admin",
"url": "https://api.twitter.com/1.1/geo/id/3cd4c18d3615bbc9.json"
}
],
"country": "United States",
"country_code": "US",
"full_name": "Toronto, IA",
"id": "173d6f9c3249b4fd",
"name": "Toronto",
"place_type": "city",
"url": "https://api.twitter.com/1.1/geo/id/173d6f9c3249b4fd.json"
},
{
"attributes": {},
"bounding_box": {
"coordinates": [
[
[
-95.956873,
37.792724
],
[
-95.941288,
37.792724
],
[
-95.941288,
37.803752
],
[
-95.956873,
37.803752
]
]
],
"type": "Polygon"
},
"contained_within": [
{
"attributes": {},
"bounding_box": {
"coordinates": [
[
[
-102.051769,
36.993016
],
[
-94.588387,
36.993016
],
[
-94.588387,
40.003166
],
[
-102.051769,
40.003166
]
]
],
"type": "Polygon"
},
"country": "United States",
"country_code": "US",
"full_name": "Kansas, US",
"id": "27c45d804c777999",
"name": "Kansas",
"place_type": "admin",
"url": "https://api.twitter.com/1.1/geo/id/27c45d804c777999.json"
}
],
"country": "United States",
"country_code": "US",
"full_name": "Toronto, KS",
"id": "b90e4628bff4ad82",
"name": "Toronto",
"place_type": "city",
"url": "https://api.twitter.com/1.1/geo/id/b90e4628bff4ad82.json"
}
]
}
}