AdSense Checker w/ Twilio Call, SMS & Email Alerts

Many moons ago I posted a little script that I had made. It scraped the AdSense UI, extracted some top line figures (revenue so far today, yesterday’s revenue amount) and printed it out in simple HTML. The main purpose was to allow me to check my AdSense revenue on-the-go without utilising a 3rd party service (which is a security no-no). After some further hacking, the script also made a prediction for the day’s income (using an understanding of the intraday trending of revenue during a typical day) which was handy for knowing how your revenue was shaping out for that day.

Anyway, all that broke some months ago (scraping data puts you at the mercy of updates that can instantly self-destruct everything). I’ve now had it re-made using the official AdSense API, thus making it full-proof for the indefinite future. I’ve been flexing my own development skills recently, so managed to also tack on the Twilio API. So now I have the script execute once daily (shortly after the stroke of midnight PST time when Adsense starts a new day), and it sends me an SMS and makes a phone call (using text-to-voice) to let me know how things are going. I also added an email alert if yesterday’s revenue was below an accepted threshold. Now the whole script has a real use-case – it let’s you know when things are going amiss, letting you take immediate action to rectify issues. You can hack it to make it work how you want it – so you only get a SMS if the revenue is below a threshold, and maybe a phone call just on super good days.

Download the script here. I was going to get fancy and put it on Github as an open source thing. Let’s see if anyone finds it useful first. Warning: the code is a mess. But it works, just. You’ll need to go through the code and make a bunch of changes for your setup, replacing “XXXXXXXXXXXXXX” with your API keys and what-not. Feel free to make improvements and share them back :)

 Tags: Random   Published: 21st May '13


No Archived Wordpress Comments