Some fun and experiments with Golang, Twitter and IBM Cloud Code Engine. Tweet at schedule with the message composed of latest IBM Cloud blog entries.
Read more:
- cron-like scheduling on IBM Cloud
- The Time for Events: Cron-like Jobs in the Cloud
- Serverless Twitter Bot using IBM Cloud
- Set up a Code Engine (CE) project.
- Add access to a container registry in Code Engine.
- Configure a local file .env with credentials / secrets. Check .env.template for a template.
- Create a secret from file.
- Build the container image, either in CE or using the Container Registry
- Create the CE app from the image and pass the configured secrets / credentials.
- Set up the CE cron subscription and pass the secret key, e.g.,
or
ibmcloud ce sub cron create -n tweety --destination twitterbot --path /tweet --schedule '07 4,8,13,17 * * *' --data 'SECRET_KEY=SET_YOUR_SECRET' --ct 'application/x-www-form-urlencoded'ibmcloud ce sub cron create -n tweety --destination twitterbot --path /tweet --data '{"secret_key":"SET_YOUR_SECRET","tweet_string2":"Written in #Golang by @data_henrik and running on #IBMCloud #CodeEngine", "item_range":10}' --content-type 'application/json' --schedule '07 9,17 * * *'
- configure .env
go run twitterBot.gocurl -X POST localhost:8080/tweet -H "Content-Type: application/json" --data '{"secret_key":"SET_YOUR_SECRET", "feed":"https://blog.4loeser.net/feeds/posts/default","tweet_string1":"@data_henrik recently wrote about %s. The #blog post is available at %s. "}

