Reject script for nuisance Twilio calls

If you’re using Twimlets to forward your calls from a Twilio number, and you’ve been getting loads of weird calls from numbers, here’s a quick fix.

<?php echo “<?xml version=\”1.0\” encoding=\”UTF-8\”?>”; ?>

<?php $from = $_REQUEST[‘From’];
if (strpos($from,’266696687′) !== false) { ?>
<Reject />
<?php } else { ?>
<Dial callerId=”<?php echo $_REQUEST[‘From’]; ?>”>+YOUR_FORWARDING_NUMBER</Dial>
<?php } ?>


  • Upload that to any server with PHP
  • Go to your Twilio phone numbers and select the offending number
  • Copy your current Request Url to the Fallback Url
  • Add the URL to your script as the Request Url
  • Save

In this case we were receiving calls from +266696687 (Anonymous) so that number is being rejected in the above script.

No comments yet.

Leave a Reply

Powered by WordPress. Designed by Woo Themes