SMS reminders Using Amazon SNS
- If you haven't already, you'll want to sign up for AWS and SNS.
- Head over to your IAM console, add a user called "sns-reminders", with "Programmatic access" is checked, attaching the policy
AmazonSNSFullAccess
and get theAccess key ID
andSecret access key
. - Create a new topic with
{'name':'sns-reminders', 'Display Name':'REMINDERS'}
and then subscribe your mobile number to that topic. Get the topic details "Topic ARN" and "Region". - create a
credentials
file at~/.aws/
andchmod 600 credentials
, and then you can copy and paste theaws_access_key_id
andaws_secret_access_key
to replace their placeholders in your~/.aws/credentials
file.
[sns-reminders]
aws_access_key_id = YOUR_AWS_ACCESS_KEY_ID
aws_secret_access_key = YOUR_AWS_SECRET_ACCESS_KEY
- Now let's send our first message! Open the project folder in your command line and type the following command:
$ php send.php "Walk your dogs now!"
- Cron Your Way to Good Habits
$ crontab -e
0 10 * * * php ~/sns-reminders/send.php "Walk your dogs now!" >> ~/sns-reminders/cron.log 2>&1