This week at Will Hall Online we’ve been building a system on one of our sites which periodically tweets a link to an existing piece of content, along with some custom text, a description and hashtags.
Possible solutions included:
We went for the third option in the end, firstly because the working of the
twitter_queue module were somewhat mysterious, and secondly because writing a custom module seemed like unnecessary extra effort when we could just use the enormously powerful views and rules modules to come up with something robust and flexible.
A quick read-up on the functioning of the Twitter Post module happily led us to (http://drupal.stackexchange.com/questions/50796/how-can-i-auto-tweet-any-node-of-a-specific-type-to-twitter)[this post on Stack Exchange (thanks filmoreha)], which pointed us generally in the right direction. However, it’s a bit sketchy on the details, so we thought we’d blog something that steps you through it a bit more.
The process, as loosely outlined by filmoreha, is as follows:
Install and enable Rules, Views, Views Bulk Operations, Flag and Twitter, if you haven’t already.
Set up the Twitter module to utilise a twitter account.
Create a flag to be used to denote which content needs tweeting. Make it a global flag which can only be used by administrator level users.
Build a view which displays an unformatted list of the titles of all of the content you want to tweet, and a views bulk operations field which includes the ability to flag and deflag content.
Flag all of this content with the flag using views bulk ops. You may want to sort your content at this point as well.
Change the filter on the view so that it only displays flagged content.
Create a rule triggered when cron is run, which has three actions:
That should be sufficient to get the site tweeting content every time cron is run.