Skip to content

Instantly share code, notes, and snippets.

@Adron
Created December 7, 2018 21:47
Show Gist options
  • Save Adron/90c134fdc2b30058686eff268df86bc7 to your computer and use it in GitHub Desktop.
Save Adron/90c134fdc2b30058686eff268df86bc7 to your computer and use it in GitHub Desktop.
This is the core findem implementation that goes out, grabs some basic information about a Twitter user and displays it to the screen.
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Starting Twitter Information Retrieval.")
completedTwitterList := buildTwitterList()
fmt.Printf("Getting Twitter details for: \n%s", completedTwitterList)
accessToken, err := getBearerToken(viper.GetString("consumer_api_key"), viper.GetString("consumer_api_secret"))
check(err)
config := &oauth2.Config{}
token := &oauth2.Token{AccessToken: accessToken}
// OAuth2 http.Client will automatically authorize Requests
httpClient := config.Client(context.Background(), token)
// Twitter client
client := twitter.NewClient(httpClient)
// users lookup
userLookupParams := &twitter.UserLookupParams{ScreenName: completedTwitterList}
users, _, _ := client.Users.Lookup(userLookupParams)
fmt.Printf("\n\nUsers:\n%+v\n", users)
howManyUsersFound := len(users)
fmt.Println(howManyUsersFound)
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment