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

Filtering picture messages


Since we're opening this up to allow others to send photos to our gallery, we want to keep it family friendly. We're going to do this by adding two types of checks.

The first check will make sure that the message doesn't contain any obscene words and the second will be to check the image to make sure there's no nudity.

Getting ready

The complete code for this recipe can be found in the Code/Recipe4/ folder.

How to do it…

We're going to modify our photo gallery to check incoming messages for profanity and inappropriate photos.

  1. First, upload ImageFilter.class.php to your photo gallery site.

  2. Next, update functions.php, which adds the profanity filter checker with the following code:

    <?php
      function cache_image( $imageurl = '',$name ){
        $imagename = $name.'.'.get_image_extension($imageurl);
        if(file_exists('./tmp/'.$imagename)){return 'tmp/'.$imagename;} 
        $image = file_get_contents_curl($imageurl); 
        file_put_contents('tmp/'.$imagename,$image);
        return...