Commit db80d06f7c4d5ce5ae29cbe1ad79a92a56aac0ad

Authored by James McMinn
1 parent 7b408d763c
Exists in master

Modified stuctures to include URL data and fixed some json tags.

Showing 2 changed files with 31 additions and 31 deletions Side-by-side Diff

... ... @@ -7,6 +7,7 @@ import (
7 7  
8 8 // Fills a channel with data from the Twitter gardenhose.
9 9 func FillStream(channel chan Tweet, consumerKey, consumerSecret, ot, osec string) {
  10 + done := make(chan bool)
10 11 httpstream.OauthCon = oauth.NewConsumer(
11 12 consumerKey,
12 13 consumerSecret,
... ... @@ -25,8 +26,6 @@ func FillStream(channel chan Tweet, consumerKey, consumerSecret, ot, osec string
25 26 channel <- JSONtoTweet(line)
26 27 }))
27 28  
28   - err := client.Sample(nil)
29   - if err != nil {
30   - httpstream.Log(httpstream.ERROR, err.Error())
31   - }
  29 + go client.Sample(done)
  30 + <-done
32 31 }
... ... @@ -5,50 +5,51 @@ import (
5 5 )
6 6  
7 7 type Tweet struct {
8   - Id int64 `json:"id"`
  8 + ID int64 `json:"id"`
  9 + FilterLevel string `json:"filter_level"`
9 10 Text string `json:"text"`
10 11 Coordinates interface{} `json:"coordinates"`
11 12 Created_at_str string `json:"created_at"`
12 13 Lang string `json:"lang"`
13   - Timestamp int64
  14 + Timestamp int64 `json:"timestamp"`
14 15 Entities struct {
15 16 Hashtags []struct {
16   - Text string
17   - Indices []int
  17 + Text string `json:"text"`
  18 + Indices []int `json:"indices"`
18 19 } `json:"hashtags"`
19 20 Urls []struct {
20   - Url string
21   - Display_url string
22   - Expanded_url string
23   - Indices []int
  21 + Url string `json:"url"`
  22 + Display_url string `json:"display_url"`
  23 + Expanded_url string `json:"expanded_url"`
  24 + Indices []int `json:"indicies"`
24 25 } `json:"urls"`
25 26 User_mentions []struct {
26   - Id int
27   - Screen_name string
28   - Name string
29   - Indices []int
  27 + Id int64 `json:"id"`
  28 + Screen_name string `json:"screen_name"`
  29 + Name string `json:"name"`
  30 + Indices []int `json:"indices"`
30 31 } `json:"user_mentions"`
31 32 Media []struct {
32   - Media_url_https string
33   - Media_url string
  33 + Media_url_https string `json:"media_url_https"`
  34 + Media_url string `json:"media_url"`
34 35 } `json:"media"`
35 36 } `json:"entities"`
36 37 Place interface{} `json:"place"`
37 38 User struct {
38   - Statuses_count int
39   - Name string
40   - Description string
41   - Location string
42   - Verified bool
43   - Followers_count int
44   - Profile_image_url_https string
45   - Url string
46   - Screen_name string
47   - Friends_count int
48   - Created_at string
49   - Id uint64
  39 + Statuses_count int `json:"statuses_count"`
  40 + Name string `json:"name"`
  41 + Description string `json:"description"`
  42 + Location string `json:"location"`
  43 + Verified bool `json:"verified"`
  44 + Followers_count int `json:"followers_count"`
  45 + Profile_image_url_https string `json:"profile_image_url_https"`
  46 + Url string `json:"url"`
  47 + Screen_name string `json:"screen_name"`
  48 + Friends_count int `json:"friends_count"`
  49 + Created_at string `json:"created_at"`
  50 + Id uint64 `json:"id"`
50 51 } `json:"user"`
51   - Retweeted_status interface{}
  52 + Retweeted_status interface{} `json:"retweeted_status"`
52 53 }
53 54  
54 55 // Converts a Twitter JSON object into a Tweet struct