With my last post I talked about having to take eye drops every hour when I’m awake and then an ointment for while I’m asleep. I thought it would be hard remember to put them in and keep track if I had done it for this hour yet or not so I wanted to set reminders for myself.
On my phone I have almost all notifications turned off but on my Fitbit I do get notified of phone calls or text messages. Very rarely do I get either of those so typically when I do it is something important. Instead of setting an alarm for every hour of the day I thought I could finally try out the Twilio trial I had signed up for some time ago and send myself a text message every hour from 6am to 10pm. It was surprisingly easy to setup.
I’m most familiar with php and I’ve been really limiting my screen time so I can rest my eyes. I haven’t worn my glasses in days so it’s a strain to read without them and keeping them closed is when they feel the best.
Here’s the very simple setup I did, most all of it came directly from the Twilio documentation and all of it was done from the terminal.
- Signup for a Twilio account.
- Create a new site on an existing hosting account I have.
- Downloaded the Twilio PHP SDK using Composer.
I’m not really familiar with Composer but these are the commands I used:- Download Composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"
- Download the SDK
php composer.phar require twilio/sdk
- Download Composer
- Create a new php file with the following code
<?php require_once 'vendor/autoload.php'; $sid = "ACxxxxxx"; // Your Account SID from www.twilio.com/console $token = "xxxxxx"; // Your Auth Token from www.twilio.com/console $client = new Twilio\Rest\Client($sid, $token); $message = $client->messages->create( '+15555555555', // Send text from this number array( 'from' => '+15555555555', // From a valid Twilio number 'body' => 'Take your drops' ) ); print $message->sid;
- Create a cronjob to run the hours you want and visit the webpage
0 6-22 * * * wget -q --read-timeout=0.0 --waitretry=5 --tries=5 --background http://{url for file created above}
Now I get a text ever hour on the hour from 6am to 10pm and my FitBit notifies me that it’s time to put in the drops.
Well all that code is totally Greek to me, as the saying goes, but awesome that you were able to do all that and it worked! 😀
LikeLiked by 1 person