24 lines
564 B
Go
24 lines
564 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/dghubble/go-twitter/twitter"
|
||
|
"github.com/dghubble/oauth1"
|
||
|
)
|
||
|
|
||
|
func makeTwitter() (*twitter.Client, error) {
|
||
|
config := oauth1.NewConfig(*twitterConsumerToken, *twitterConsumerSecret)
|
||
|
token := oauth1.NewToken(*twitterAPIKey, *twitterAPISecret)
|
||
|
// http.Client will automatically authorize Requests
|
||
|
httpClient := config.Client(oauth1.NoContext, token)
|
||
|
|
||
|
// twitter client
|
||
|
client := twitter.NewClient(httpClient)
|
||
|
|
||
|
_, _, err := client.Accounts.VerifyCredentials(nil)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return client, nil
|
||
|
}
|