func getTwitterClient() *tw.Client {
	var twitterClient *tw.Client
	twitterClient = tw.NewClient()

	consumerKey := os.Getenv("TWITTER_CONSUMER_KEY")
	consumerSecret := os.Getenv("TWITTER_CONSUMER_SECRET")

	if err := twitterClient.SetKeys(consumerKey, consumerSecret); err != nil {
		log.Fatalf("Failed to get credentials: %s", err)
	}

	return twitterClient
}
Beispiel #2
0
func init() {
	key_file := os.Getenv("TWITTER_KEYS_FILE")
	buf, err := ioutil.ReadFile(key_file)
	if err != nil {
		log.Fatalf("Failed to read keys file: %s", err)
	}
	for _, line := range strings.Split(string(buf), "\n") {
		if line != "" {
			kb.AddKey(kb.Key{Value: line})
		}
	}
	tc = tw.NewClient()
	if err = rotateKeys(); err != nil {
		log.Fatalf("Failed to set keys: %s", err)
	}
}