Created
November 13, 2015 10:53
-
-
Save gngeorgiev/f7af752edf8b16a39a41 to your computer and use it in GitHub Desktop.
Twitter analyze spike
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/ChimeraCoder/anaconda" | |
"net/url" | |
"fmt" | |
) | |
func main() { | |
anaconda.SetConsumerKey("54EgkqrPnKv8pVaKUhJhqmu3z") | |
anaconda.SetConsumerSecret("r2wBT4GzKyqkPU4kcYY9n3Omw0GnQHEGEFqN86dXLAnhkVuZEO") | |
tw := anaconda.NewTwitterApi("3258542776-mJPVFKxKcBAjhoB8AhpgRTtgfKvDZG9Fhpr5nl6", "Mu5YodFtueSov8Roy0l0epdJ8kc5LdsqfcK7auYOpuq50") | |
fmt.Println("Gettings followers ids....") | |
followersValues := url.Values{} | |
followersValues.Set("screen_name", "TrainMate") | |
followersIdsChan := tw.GetFollowersIdsAll(followersValues) | |
followersRes := <-followersIdsChan | |
fmt.Println(fmt.Sprintf("Got %s followers", len(followersRes.Ids))) | |
ids := make([]int64, 100) | |
for i, id := range followersRes.Ids { | |
if i == 100 { | |
break | |
} | |
ids[i] = id | |
} | |
fmt.Println("Getting followers profiles...") | |
users, err := tw.GetUsersLookupByIds(ids, nil) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
fmt.Println("Done") | |
for _, user := range users { | |
fmt.Println(fmt.Sprintf("Getting tweets of %s...", user.ScreenName)) | |
userTimelineValues := url.Values{} | |
userTimelineValues.Set("screen_name", user.ScreenName) | |
userTimelineValues.Set("include_rts", "false") | |
tweets, err := tw.GetUserTimeline(userTimelineValues) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
for _, tw := range tweets { | |
fmt.Println(tw.Text) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment