Skip to content

Instantly share code, notes, and snippets.

@fayimora
Last active December 4, 2016 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fayimora/b5cde521695e9683e3580a4af4bb8cfe to your computer and use it in GitHub Desktop.
Save fayimora/b5cde521695e9683e3580a4af4bb8cfe to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/dghubble/go-twitter/twitter"
"github.com/dghubble/oauth1"
)
func main() {
config := oauth1.NewConfig("---", "---")
token := oauth1.NewToken("---", "---")
httpClient := config.Client(oauth1.NoContext, token)
// Twitter client
client := twitter.NewClient(httpClient)
// Verify Client
verifyParams := &twitter.AccountVerifyParams{
SkipStatus: twitter.Bool(true),
IncludeEmail: twitter.Bool(true),
}
// My User
user, _, _ := client.Accounts.VerifyCredentials(verifyParams)
fmt.Printf("My ACCOUNT:\n%+v\n", user)
// Followers
friends, _, _ := client.Friends.IDs(&twitter.FriendIDParams{})
// followers, resp, err := client.Followers.List(&twitter.FollowerListParams{})
for _, friendID := range friends.IDs {
userShowParams := &twitter.UserShowParams{UserID: friendID}
dmParams := &twitter.DirectMessageNewParams{UserID: friendID, Text: "Hello!"}
dm, _, err := client.DirectMessages.New(dmParams)
fmt.Println(dm)
fmt.Println("======================")
fmt.Println(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment