Book Image

Twilio Cookbook: Second Edition

By : Roger Stringer
Book Image

Twilio Cookbook: Second Edition

By: Roger Stringer

Overview of this book

Table of Contents (20 chapters)
Twilio Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Monitoring a website


I own nearly twenty websites; if those sites go down, my clients get mad. This recipe is a handy recipe to monitor a list of websites every five minutes and, if the site is unreachable, send out a text message.

We're going to use a simple key-value pair datastore system that will store the URL and the current status of the site in a file. If the site is down, we will send a notification to a list of users. Then, if the site is back up the next time the script runs, we will send another notification to the users to tell them that the site is up.

Getting ready

The complete source code for this recipe can be found in the Chapter6/Recipe8/ folder.

How to do it...

This recipe will build a simple website monitor that we will set up to check a list of sites every five minutes.

  1. Download the Twilio Helper Library from https://github.com/twilio/twilio-php/zipball/master and unzip it.

  2. Upload the Services/ folder to your website.

  3. Upload config.php to your website and make sure the following...