ChimeraCoder / anaconda

A Go client library for the Twitter 1.1 API
MIT License
1.14k stars 247 forks source link

How to subscribe some users realtime tweets? #256

Closed nifflin closed 6 years ago

nifflin commented 6 years ago

twtapi.UserStream(url.Values{"with": []string{"realDonaldTrump", "BarackObama", "myownusername"}}) I tested it, this doesn't work. Just get a lot of nil tweet pointer from anaconda.Stream. Thank you.

dijit commented 6 years ago

Probably something like:

func main() {
        api := anaconda.NewTwitterApiWithCredentials(
                access_token,
                access_token_secret,
                consumer_key,
                consumer_secret,
        )

        v := url.Values{}
        s := api.PublicStreamFilter(v)
        v.Add("follow", "15209123") // 15209123 = @dijit
        log.Info(v.Encode())

        for t := range s.C {
                switch v := t.(type) {
                case anaconda.Tweet:
                logrus.Infof("%-15s: %s\n", v.User.ScreenName, v.Text)
            }
        }
}
muesli commented 6 years ago

Sorry, but I think the public streams have been shut down by Twitter.

nifflin commented 6 years ago

Sorry, but I think the public streams have been shut down by Twitter.

I tested it a few days ago, it works, but NOT stable. The result output stream could be shut down any time.