Skip to content

Instantly share code, notes, and snippets.

View mickstevens's full-sized avatar

Mick Stevens mickstevens

View GitHub Profile
<?php
// Set the numbers to call
$numbers = array("<number to call 1>", "<number to call 2>", "<number to call n>");
$number_index = isset($_REQUEST['number_index']) ? $_REQUEST['number_index'] : "0";
$DialCallStatus = isset($_REQUEST['DialCallStatus']) ? $_REQUEST['DialCallStatus'] : "";
header("content-type: text/xml");
// Check the status of the call and
<?php
// From http://ertw.com/blog/2013/11/05/using-an-ip-phone-with-twilio/
// Connect an incoming call to your SIP phone through Twilio
$called = preg_replace('/sip:1?(.*?)@.*/', '{$1}', $_POST['Called']);
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
@mickstevens
mickstevens / golang-twilio-voice.go
Created October 23, 2014 13:31
Twilio Voice App using Golang
package main
import (
"encoding/xml"
"net/http"
"net/url"
"fmt"
"strings"
"io/ioutil"
"encoding/json"
console.log('Loading event');
// Twilio Credentials
var accountSid = '';
var authToken = '';
var fromNumber = '';
var https = require('https');
var queryString = require('querystring');
import zillabyte
twilio_sid = "SID_HERE"
twilio_auth = "AUTH_HERE"
class TwilioEach:
def prepare(self, controller):
# Dictionary of phone numbers subscribed to cities (just for show with small sample, please use a
# REAL source when using a significant number of phone numbers)
import zillabyte
from twilio.rest import TwilioRestClient
def send_text(controller, tup):
# Register twilio client
twilio_client = TwilioRestClient(tup["twilio_sid"], tup["twilio_auth"])
try:
# Send message to recipient and wait 1 second (twilio SMS rate limit)
/* O U T O F O F F I C E F O R T W I T T E R */
/* - - - - - - - - - - - - - - - - - - - - - */
/* Written by Amit Agarwal http://labnol.org?p=27911 */
/* For customization and support, see http://ctrlq.org */
function start() {
{
"sparkAccessToken": "",
"sparkDeviceID": "",
"twilioAccountSID": "",
"twilioAuthToken": "",
"toPhoneNumber": "[NUMBER TO CALL]",
"fromPhoneNumber": "[YOUR TWILIO NUMBER]",
"paperTowelTwiml": "[URL TO TWIML FILE. DROPBOX WORKS GREAT]"
}
@mickstevens
mickstevens / call.php
Last active August 29, 2015 14:21 — forked from jonmarkgo/call.php
<?php
require("Services/Twilio.php");
require("database.php");
// require POST request
if ($_SERVER['REQUEST_METHOD'] != "POST") die;
// generate "random" 6-digit verification code
$code = rand(100000, 999999);
<?php
$db_host='dbserver';
$db_name='dbame';
$db_user='dbuser';
$db_passwd='dbpassword';
mysql_connect($db_host, $db_user, $db_passwd)
or die('Could not connect: ' . mysql_error());
mysql_select_db($db_name) or die('Could not select database');