Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am akjordan on github.
  • I am andrewkirk (https://keybase.io/andrewkirk) on keybase.
  • I have a public key ASDJRWD8o0RMpN4MLM1Utp1B1nXQH2xQ_prs3z3Sl25VaQo

To claim this, I am signing this object:

@akjordan
akjordan / conf.js
Created September 13, 2016 19:34
Conf.js
const crypto = require('crypto');
const respond = (callback, contents) => callback(null, {
status: '200',
body: `<?xml version="1.0" encoding="UTF-8"?><Response>${contents}</Response>`,
headers: {
'Content-Type': 'application/xml',
},
});
console.log('Loading function');
exports.handler = function(event, context) {
var output ='<?xml version="1.0" encoding="UTF-8"?><Response><Pause length="2"/><Say>Hello Amazon, this is Twilio powered by Lambda</Say></Response>';
context.succeed(output);
};
// Twilio sends requests with content type application/x-www-form-urlencoded
// To enable API gateway to parse them you need to go to Integration Request
// Under Integration Request go to Mapping Templates and set content type to
{
"lambda": {
"FunctionName": "twilio-blueprint",
"Description": "A simple backend for handling events sent from Twilio.",
"Timeout": 15
},
"version": "0.1.0",
"build": "https://s3.amazonaws.com/twilio-media/lambda.zip",
"endpoints": {
"api-gateway": [
get_or_post '/*' do
t = Time.now
if ((t.monday? || t.tuesday?) && t.hour >= 17) || ((t.tuesday? || t.wednesday?) && t.hour <= 12)
msg = 'Recycling is closed'
elsif (t.thursday? && t.hour >= 17) || (t.friday? && t.hour <= 12)
msg = 'Everything is closed'
else
msg = 'Everything SHOULD be unlocked'
end
@akjordan
akjordan / client_page.html
Created May 3, 2014 02:28
Client Starter
<!DOCTYPE html>
<html>
<head>
<title>Hello Client</title>
<script type="text/javascript"
src="//static.twilio.com/libs/twiliojs/1.2/twilio.min.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
</script>
<link href="http://static0.twilio.com/packages/quickstart/client.css"
calllead.php
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "AC25e16e9a716a4a1786a7c83f58e30482";
$token = "{{ auth_token }}";
$client = new Services_Twilio($sid, $token);
@akjordan
akjordan / forcedelivery.cs
Last active December 28, 2015 04:29
Modifying Messages.cs to allow for the use of ForceDelivery = false
public virtual Message SendMessage(string from, string to, string body, string[] mediaUrls, string statusCallback, string applicationSid, string forceDelivery)
{
Require.Argument("from", from);
Require.Argument("to", to);
var request = new RestRequest(Method.POST);
request.Resource = "Accounts/{AccountSid}/Messages.json";
request.AddParameter("From", from);
request.AddParameter("To", to);
@akjordan
akjordan / randomsms.rb
Last active December 26, 2015 22:19
Send SMS from a randomized array of numbers in Ruby.
# twilio-ruby install docs at twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'
# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = '{{ account_sid }}'
auth_token = '{{ auth_token }}'
@client = Twilio::REST::Client.new account_sid, auth_token
numbers = [number1, number2, number3, numberN]
@akjordan
akjordan / gist:6323160
Created August 23, 2013 19:39
Send SMS via curl
curl -XPOST https://api.twilio.com/2010-04-01/Accounts/AC25e16e9a716a4a1786a7c83f58e30482/SMS/Messages.json \
-d "Body=Jenny%20please%3F%21%20I%20love%20you%20<3" \
-d "To=%2B1234567890" \
-d "From=%2B16173793557" \
-u 'AC25e16e9a716a4a1786a7c83f58e30482:Token'