Skip to content

Instantly share code, notes, and snippets.

View RobSpectre's full-sized avatar

Rob Spectre RobSpectre

View GitHub Profile
@RobSpectre
RobSpectre / listTollFree.php
Created November 9, 2011 22:37
List TollFree phone numbers in PHP
<?php
require_once('Services/Twilio.php');
require_once('auth.php');
$client = new Services_Twilio($ACCOUNT_SID, $AUTH_TOKEN);
$list = $client->account->available_phone_numbers->getList('US', 'TollFree');
foreach ($list->available_phone_numbers as $num) {
print_r($num);
@RobSpectre
RobSpectre / sms.php
Created November 11, 2011 17:08
Receive a "1" in the body
<?php
if (isset($_REQUEST['Body'])) {
$body = $_REQUEST['Body'];
} else {
$body = False;
}
if ($body && $body == "1") {
$message = "1 is active.";
// Add additional logic here...
@RobSpectre
RobSpectre / linebreak.php
Created November 16, 2011 16:15
Line break in a Twilio SMS
<?php
$ACCOUNT_SID = "ACxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$AUTH_TOKEN = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
$TWILIO_NUMBER = "+1aaabbbcccc";
$TEST_NUMBER = "+1xxxyyyzzzz";
include 'Services/Twilio.php';
$client = new Services_Twilio($ACCOUNT_SID, $AUTH_TOKEN);
$client->account->sms_messages->create(
@RobSpectre
RobSpectre / linebreak_with_simplexml.php
Created November 16, 2011 16:35
Line break in a Twilio SMS using SimpleXML
<?php
$ACCOUNT_SID = "ACxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$AUTH_TOKEN = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
$TWILIO_NUMBER = "+1aaabbbcccc";
$TEST_NUMBER = "+1xxxyyyzzzz";
include 'Services/Twilio.php';
// Use SimpleXML to get the message body.
$xml = <<<XML
@RobSpectre
RobSpectre / female_time.xml
Created November 16, 2011 16:47
Change voice of Twilio Say
<Response>
<Say voice="woman">The time is 1:00 pm</Say>
</Response>
@RobSpectre
RobSpectre / xml.php
Created November 20, 2011 01:51
SimpleXML Example
<?php
$xml = new SimpleXMLElement("<Response/>");
$reject = $xml->addChild("Accept");
$reject->addAttribute("Reason", "This buyer is not awesome.");
echo $xml->asXML();
?>
@RobSpectre
RobSpectre / sms_forward.php
Created November 23, 2011 20:49
SMS forwarding
<?php
header('Content-type: text/xml');
$message = $_REQUEST['Body'];
?>
<Response>
<Sms to="{{YOUR_NUMBER}}"><?php echo $message; ?></Sms>
</Response>
@RobSpectre
RobSpectre / lecture.php
Created January 9, 2012 23:10
Faking audio scrubbing using discrete audio chunks
<?php
// Include Twilio helper library
require("Services/Twilio.php");
// Instantiate Twilio Response object to render TwiML.
$response = new Services_Twilio_Twiml();
$gather = $response->gather(array('numDigits' => 1));
if (isset($_REQUEST['Digits'])) {
$gather-say('Playing part '.$_REQUEST['Digits']);
@RobSpectre
RobSpectre / 1_twiml.xml
Created January 10, 2012 04:35
Your TwiML application - "APxxxxx"
<Response>
<Play>sound_file.mp3</Play>
</Response>
@RobSpectre
RobSpectre / app.py
Created January 23, 2012 22:30
SMS Birthday Card Step 4: Add a HELP keyword.
from flask import Flask
from flask import request
import os
from random import choice
from twilio import twiml
app = Flask(__name__)