Skip to content

Instantly share code, notes, and snippets.

@TMcManus
TMcManus / gist:1711143
Created January 31, 2012 15:42
Number Formatting Functions
<?php
/**
* This function will take a number in a variety of formats and reformat
* the number to be in E.164 format. Currently this is really, really ugly,
* but it works. substr() based function might also work. Currently US only.
*/
function normalizeNumber($number) {
$number = trim($number);
$number = preg_replace("/[^A-Za-z0-9]/", '', $number);
@TMcManus
TMcManus / uk_area_codes_list.php
Created February 9, 2012 16:21
List Twilio UK Area Codes
<?php
/**
* This script requires a Twilio Account and the Twilio PHP Helper Library,
* which can be found at http://www.twilio.com/docs/libraries
*/
// Require Twilio Helper Library
require('Services/Twilio.php');
@TMcManus
TMcManus / README.txt
Created March 8, 2012 01:18
Simple Twilio Conditional Logic
---- Setting up this script ----
1) Upload these files to a location that is publicly accessible on the internet.
2) Enter the URL of the file named "index.xml" into the Voice Request URL of the number you want to setup.
@TMcManus
TMcManus / form.html
Created March 13, 2012 00:30
Simple Form to SMS
<form action="form_to_sms.php" method="post">
<label for="phone">Phone Number</label>
<input type="tel" name="phone"/><br/>
<label for="body">Message Body</label>
<textarea name="body" maxlength="160"></textarea><br/>
<input type="submit" />
</form>
@TMcManus
TMcManus / fix_idea.php
Created March 22, 2012 16:43
Auto-responder Fix idea
<?php
$twilio_welcome_message = "Welcome to Twilio SMS. Configure your number's SMS URL to change this message. Reply HELP for help. Reply STOP to unsubscribe. Msg&Data rates may apply.";
if($_RESPONSE['Body'] != $twilio_welcome_message){
echo("<Sms>Welcome to Twilio SMS. Configure your number's SMS URL to change this message. Reply HELP for help. Reply STOP to unsubscribe. Msg&Data rates may apply.</Sms>");
}
@TMcManus
TMcManus / create_database.php
Created April 27, 2012 22:52
<Gather> a birthday with Twilio
<?php
$db = new PDO('sqlite:database.sqlite');
// Create the SQLite table.
$db->exec('CREATE TABLE gather_date (id INTEGER PRIMARY KEY, call_sid TEXT(32), year TEXT(4), month TEXT(2), day TEXT(2));');
// Populate it with some data
$db->exec("INSERT INTO gather_date (call_sid, year, month, day) VALUES ('fhsdhfiuh', '2010', '09', '01');");
if (file_exists('database.sqlite'))
@TMcManus
TMcManus / validation.php
Created April 30, 2012 04:45
Phone Number Validation Link for Twilio
<?php
/**
* Include the offical Twilio PHP Helper Library, which can be found at
* http://www.twilio.com/docs/libraries
*/
include 'Services/Twilio.php';
// Your Twilio Credentials
$accountSid = 'AC1987654gef...'; // Replace with your own Account Sid
@TMcManus
TMcManus / send-sms-from-a-number-pool.php
Created October 3, 2012 21:43
How to send SMS Messages from a pool of numbers
<?php
// Sending SMS messages from a pool of numbers
// Load the Twilio PHP Helper Library
// This library can be downloaded from: https://github.com/twilio/twilio-php
require('Services/Twilio.php');
// Fill in your account credentials
$sid = "ACXXXXXXX"; // Your Account SID from www.twilio.com/user/account
$token = "YYYYYYY"; // Your Auth Token from www.twilio.com/user/account
@TMcManus
TMcManus / README.md
Created October 4, 2012 00:43
Risky Account Finder

Installation and Use

  1. In a python environment that has pip installed, do pip install twilio then pip install phonenumbers.
  2. Do python risky-account-finder.py
@TMcManus
TMcManus / call-download.php
Last active August 18, 2024 22:49
Twilio Call Log CSV Download Script
<?php
/**
* Download the library from: https://github.com/twilio/twilio-php
* Copy the 'Services' folder into a directory containing this file.
*/
require('Services/Twilio.php');
$account_sid = "ACXXXXXXXXXXX"; // Your Twilio account sid
$auth_token = "YYYYYYYYYYYY"; // Your Twilio auth token