geosearch.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package anaconda
  2. import "net/url"
  3. type GeoSearchResult struct {
  4. Result struct {
  5. Places []struct {
  6. ID string `json:"id"`
  7. URL string `json:"url"`
  8. PlaceType string `json:"place_type"`
  9. Name string `json:"name"`
  10. FullName string `json:"full_name"`
  11. CountryCode string `json:"country_code"`
  12. Country string `json:"country"`
  13. ContainedWithin []struct {
  14. ID string `json:"id"`
  15. URL string `json:"url"`
  16. PlaceType string `json:"place_type"`
  17. Name string `json:"name"`
  18. FullName string `json:"full_name"`
  19. CountryCode string `json:"country_code"`
  20. Country string `json:"country"`
  21. Centroid []float64 `json:"centroid"`
  22. BoundingBox struct {
  23. Type string `json:"type"`
  24. Coordinates [][][]float64 `json:"coordinates"`
  25. } `json:"bounding_box"`
  26. Attributes struct {
  27. } `json:"attributes"`
  28. } `json:"contained_within"`
  29. Centroid []float64 `json:"centroid"`
  30. BoundingBox struct {
  31. Type string `json:"type"`
  32. Coordinates [][][]float64 `json:"coordinates"`
  33. } `json:"bounding_box"`
  34. Attributes struct {
  35. } `json:"attributes"`
  36. } `json:"places"`
  37. } `json:"result"`
  38. Query struct {
  39. URL string `json:"url"`
  40. Type string `json:"type"`
  41. Params struct {
  42. Accuracy float64 `json:"accuracy"`
  43. Granularity string `json:"granularity"`
  44. Query string `json:"query"`
  45. Autocomplete bool `json:"autocomplete"`
  46. TrimPlace bool `json:"trim_place"`
  47. } `json:"params"`
  48. } `json:"query"`
  49. }
  50. func (a TwitterApi) GeoSearch(v url.Values) (c GeoSearchResult, err error) {
  51. response_ch := make(chan response)
  52. a.queryQueue <- query{a.baseUrl + "/geo/search.json", v, &c, _GET, response_ch}
  53. return c, (<-response_ch).err
  54. }