Twitterアカウントでサインインしたユーザーが、@nekoshita_yukiのツイッターアカウントをフォローするサンプル
たとえば、あるユーザーをフォローするAPIなど、ユーザーの認証が必要なAPI https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-create
- go 1.16.0
- TwitterDeveloperPortalでAppを作成しておく
- TwitterDeveloperPortalで対象のAppで以下を設定する
App permissions
をRead and Write
にしておくAuthentication settings
を3-legged OAuth
をenabled
にしておくAuthentication settings
でCallback URLs
にhttp://localhost:8080/twitter/callback
を設定しておく
go mod vendor
ConsumerKeyを環境変数にセットする
# TwitterDeveloperPortalで、対象のAppのConsumerKeyを取得する
# https://developer.twitter.com/
$ export TWITTER_CONSUMER_KEY=xxxx
$ export TWITTER_CONSUMER_SECRET=xxxx
サーバーを起動する
$ go run main.go