Send a tweet to Twitter using Go.
This example code is a precursor for me while I am working on my hobby project ajtweet that I will be using to schedule tweets.
See my blog post for more details on how to explore the Twitter APIs and how I wrote this code.
NOTE: This uses the gotwi library for doing the heavy work.
Install the required go packages:
go mod tidy
Configure your Twitter API Key, Secret and OAuth 1 User token and secret.
cp env_example .env
# Edit the .env file.
Build the executable:
go build -o tweet .
Source the environment variables:
source .env
Send a tweet:
./tweet "Test: Hello world from golang"
tweet id 1527644512285343745