예제 #1
0
// Fetch stats from Twitter and store it for display by the web interface.
func fetchStats(api *anaconda.TwitterApi) error {
	handles := strings.Join(democrats, ",") + "," + strings.Join(republicans, ",")

	users, err := api.GetUsersLookup(handles, url.Values{})
	if err != nil {
		return err
	}

	t := make([]TwitterInfo, len(users))
	for i, u := range users {
		t[i].Name = u.Name
		t[i].Image = u.ProfileImageURL
		t[i].Followers = u.FollowersCount
		t[i].Tweets = u.StatusesCount
		for _, d := range democrats {
			if u.ScreenName == d {
				t[i].Democrat = true
				break
			}
		}
	}
	sort.Sort(ByFollowers(t))
	stats.Put(t)

	return nil
}