Skip to content

Instantly share code, notes, and snippets.

View caseysoftware's full-sized avatar

Danger Casey caseysoftware

View GitHub Profile
<?php
include 'functions.php';
header("Content-type: text/xml");
$response = new Services_Twilio_Twiml();
$response->dial($toPhone);
print $response;
<?php
include 'functions.php';
header("Content-type: text/xml");
$from = preg_replace("/[^0-9]/", "", $_POST['From']);
$response = new Services_Twilio_Twiml();
$response->dial($toPhone, array('timeout' => 5));
$response->say('Please leave your message after the tone');
<?php
include 'functions.php';
header("Content-type: text/xml");
$filter = "!@#$^&%*()+=-[]\/{}|:<>?,.";
$recording = preg_replace("/[$filter]/", "", $_POST['RecordingUrl']);
$duration = (int) $_POST['RecordingDuration'];
<?php
include 'functions.php';
header("Content-type: text/xml");
$whitelist = array('17035551212', '12025551212');
$from = preg_replace("/[^0-9]/", "", $_POST['From']);
@caseysoftware
caseysoftware / functions.php
Last active December 14, 2015 04:59
This is only part of functions.php - You can view this file in context here: https://github.com/caseysoftware/upgrading-google-voice-with-Twilio
<?php
// There is not the entire file, download the full package from Github.
{
if (in_array($number, $whitelist)) {
return true;
}
$currentHour = date('G');
if (($starttime <= $currentHour) && ($currentHour < $endtime)) {
<?php
include 'functions.php';
/**
* Now we'll combine Revision 3 with an interface to put some fine-grained
* control of the white and blacklists via SMS.
*/
$from = preg_replace("/[^0-9]/", "", $_POST['From']);
@caseysoftware
caseysoftware / functions.php
Last active December 14, 2015 04:59
This is only part of functions.php - You can view this file in context here: https://github.com/caseysoftware/upgrading-google-voice-with-Twilio
<?php
// There is not the entire file, download the full package from Github.
function process_command($message)
{
$message = preg_replace('!\s+!', ' ', $message);
$words = explode(' ', $message);
$response = "Unknown command. Use: allow, block, remove, status, or name with a phone number to manage your lists";
@caseysoftware
caseysoftware / spider.php
Created April 19, 2013 05:24
This is a really rough cut at spidering the Twilio API
<?php
$mapped = array();
spiderAPI('https://XXXX@api.twilio.com/2010-04-01');
function spiderAPI($url) {
global $mapped;
$url = str_replace('XXXX', 'ACxxxx:authToken', $url);
$xml = simplexml_load_file($url);
@caseysoftware
caseysoftware / sms-rest.php
Last active December 18, 2015 15:39
Sending an text message with PHP on Twilio
<?php
// Include the Twilio PHP library
require "Services/Twilio.php";
// Set your AccountSid and AuthToken from www.twilio.com/user/account
$AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$AuthToken = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";
// Instantiate a new Twilio Rest Client
$client = new Services_Twilio($AccountSid, $AuthToken);
@caseysoftware
caseysoftware / call-request.php
Last active December 18, 2015 15:39
Making an outbound call with PHP on Twilio
<?php
// Include the Twilio PHP library
require 'Services/Twilio.php';
// Set our Account SID and AuthToken
$sid = 'AC123';
$token = 'abcd';
// A phone number you have previously validated with Twilio
$phonenumber = '4151234567';