Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Releases: Fallenstedt/twitter-stream

v0.4.2

28 Mar 03:11
Compare
Choose a tag to compare
  • Improve error handling with delete rule method #38

v0.4.1

23 Dec 02:05
15e71f0
Compare
Choose a tag to compare

0.4.1

Summary

Changes were made to StartStream function. You can now request additional data from each tweet with a NewStreamQueryParamsBuilder

Changes to StartStream

Before

Originally, users who start a stream would need to pass in query params as a string. Users had to ensure they included a question mark. The problem with this approach was users could use unencoded reserved characters in the query string.

err := api.stream.StartStream("?expansions=foo&meta.fields=bar,baz,biz")

In addition, if a user did not want additional data for each tweet, then they would need to use an empty string.

err := api.stream.StartStream("")

After

It is recommended users use a NewStreamQueryParamsBuilder to build query params. Users should use the values described in twitter's documentation to fetch additional data they need for each tweet.

	// Request additional data from teach tweet
	streamExpansions := twitterstream.NewStreamQueryParamsBuilder().
		AddExpansion("author_id").
		AddTweetField("created_at").
		Build()

	// Start the Stream
	err = api.stream.StartStream(streamExpansions)

If no expansions are needed, users can just use nil for the url values.

	err = api.stream.StartStream(nil)

v0.4.0

11 Dec 21:29
04b1953
Compare
Choose a tag to compare
  • Update examples to showcase an infinite stream

  • Introduce CreateRulesRequest to create rules.

	rules := twitterstream.NewRuleBuilder().
		AddRule("cat has:images", "cat tweets with images").
		AddRule("puppy has:images", "puppy tweets with images").
		AddRule("lang:en -is:retweet -is:quote (#golangjobs OR #gojobs)", "golang jobs").
		Build()

	res, err := api.Rules.Create(rules, false) // dryRun is set to false.
  • Introduce a DeleteRulesRequest to delete rules.
	res, err := api.Rules.Delete(rules.NewDeleteRulesRequest(1469776000158363653, 1469776000158363654), false)

v0.3.3

25 Nov 19:32
f43d02a
Compare
Choose a tag to compare
  • Update examples to include restarting stream when twitter disconnects
  • Promote certain structs to be exported
  • Updated how interfaces are used internally
  • Corrected some typos

v0.3.2

19 Jun 22:40
c11c3e7
Compare
Choose a tag to compare
  • Handle 429 status code responses from twitter using exponential backoff #19

v0.3.1

24 May 02:21
7d90444
Compare
Choose a tag to compare

Fixes a race condition where unmarshaling json with bytes.Buffer across multiple goroutines caused panics.

SetUnmarshalHook is an optional hook allowing you to unmarshal json in a thread-safe way. By default you will stream []byte. However, this is not thread-safe.

This hook allows you to unmarshal json in the same goroutine where the bytes.Buffer was created, making it thread-safe.

See this example for how to use this hook well.

v0.3.0

02 Feb 06:20
924bfc8
Compare
Choose a tag to compare
api.Stream.StartStream("?expansions=attachments.media_keys,referenced_tweets.id,author_id")
  • GetMessages returns a struct which can contain an error from twitter, or it can contain your tweet bytes. It's now up to you to unmarshal the bytes into a struct your create.
	go func() {
		for message := range api.Stream.GetMessages() {
			if message.Err != nil {
				panic(message.Err)
			}
                        // Will print something like: 
                        //{"data":{"id":"1356479201000","text":"Look at this cat picture"},"matching_rules":[{"id":12345,"tag":"cat tweets with images"}]}
			fmt.Println(string(message.Data))
		}
	}()

v0.2.1

09 Jan 19:54
Compare
Choose a tag to compare
  • StartStream will return an error if a stream fails to start, nil if successful.
  • Pass error messages to consumer while streaming. The result is clients must handle possible errors when GetMessages is used. See readNext in stream_utils.go for possible list of errors.
  • Update README

v0.2.0

03 Jan 19:49
Compare
Choose a tag to compare
  • Rename package to twitterstream
  • RequestBearerToken now returns (*requestBearerTokenResponse, error)

0.1.0

23 Dec 06:28
Compare
Choose a tag to compare
  • Adds unit tests