示例#1
0
文件: TwitterUtil.go 项目: v0l/gobot
func (t *TwitterUtil) GetLoc(api *anaconda.TwitterApi) *TweetLocation {
	if t.LocationMode == 0 {
		rand.Seed(int64(time.Now().Unix()))

		rl := new(TweetLocation)
		rl.lat = fmt.Sprintf("%.4f", (float32(180)*rand.Float32())-float32(90))
		rl.long = fmt.Sprintf("%.4f", (float32(360)*rand.Float32())-float32(180))

		vals := url.Values{}
		vals.Add("lat", rl.lat)
		vals.Add("long", rl.long)

		pl, ple := api.GeoSearch(vals)

		rl.err = ple
		rl.result = pl

		return rl
	} else {
		return &t.Location
	}
}