Here's a quick and easy Rake task to tweet when a new post is published.
Mar 16, 2016
I use Twitter a fair bit, so I like to fire a quick tweet out to my many (not) followers when I’ve published a new
post . This task was a bit of a pain, so I thought I’d throw together a quick Rake task to do this for me.
To get this to work, you’ll need to install the twitter gem manually or, by adding it to your Gemfile.
You’ll also need to create config file that will store the API keys for the twitter gem to use to authenticate
with the Twitter API. Use the following template, enter your API keys and save it as twitter-api-credentials.yaml
right next to your Rakefile:
You can get your API keys by creating yourself an app at the Twitter dev site.
Add the following task to your Rakefile:
When you’re ready, run the task with:
… but obviously change the $TITLE_OF_POST and $URL_OF_POST parameters to those of the post that you’ve just published .