A while back, I had looked at automating tweets from a Google spreadsheet to reduce the insane number of clicks it takes to do in TweetDeck and HootSuite (5 clicks? Really?) I hit some roadblocks and let it slide because in the long run, it wasn’t really important to me. More of a fun experiment.
I jumped back into it a week or so back to try and solve the last little problems. [I was able to create a script](https://docs.google.com/spreadsheets/d/1kbFIfYGm2sGQJ5TistkaxMzqUqQ8HbgUvJUM8MohOb4/edit?usp=sharing) which loops through a spreadsheet checks the current date and whether or not the tweet has been sent. If those conditions are met (`TODAY` and `NOT SENT`), it will automatically post the tweet.
The sheet, like all the other Twitter sheets I’ve used, is run with [Martin Hawksey’s](http://twitter.com/mhawksey) fantastic TwtrService library. It allows you to authenticate and tweet right from Google Apps Script and saves a _ton_ of time.
I ran into a problem that is [as-yet unsolved](https://stackoverflow.com/questions/37308911/pause-a-loop-to-wait-for-rest-api-response): I can’t get the sheet to stop after posting one tweet. So, if you have multiple tweets on a given day, it will send _all_ of them at once. That’s not good, especially if you’re promoting an event over a period of time. I’ve tried a number of solutions, but I can’t seem to find one that works. I’d love to hear if you’re able to take the source and tweak it to work.
In the meantime, Martin also took a (much more elegant) pass at the task. [His sheet is also available](https://docs.google.com/spreadsheets/d/10U7Rrr7lfbRS2A8QYRUWL8enlJfat75-QuGm7slKXRE/edit#gid=0) and works really well. The goal is the same, but his mechanics and implementation are much more refined and effective.
It’s a good example of multiple ways to skin a cat. I’m a novice coder (I tell people I know enough to break something) and he’s an expert doing all kinds of things. The great thing is, all of this code is open and available. I can make a copy of Martin’s page and dig into his solution. I learned a few tricks about checking for multiple conditions, which is what I was struggling with. I became better at scripting through my failure and his success.Written on May 25th, 2016 by Brian Bennett Categorized in: All Projects Technology