Skip to content

Instantly share code, notes, and snippets.

View rahims's full-sized avatar

Rahim Sonawalla rahims

View GitHub Profile
@rahims
rahims / callback.php
Created April 14, 2010 19:25
Example PHP code for working with the Netflix API using the OAuthSimple library.
<?php
// OAuthSimple can be found at http://github.com/jrconlin/oauthsimple/
require_once('OAuthSimple.php');
// You'll likely want to move $consumer_key and $consumer_secret to an
// include file
$consumer_key = '[The key given to you by Netflix]';
$consumer_secret = '[The shared secret given to you by Netflix]';
$oauth_token = $_GET['oauth_token'];
@rahims
rahims / group_therapy.php
Created November 14, 2010 09:21
Code from Twilio talk given at the L.A. Hacker News Meetup on 11/13/2010
<?php
/*
* Code from Twilio talk given at the L.A. Hacker News Meetup on 11/13/2010
*
* During the talk, everyone was asked to vote (vote.php) whether they were
* awesome or not (text "1" for awesome, anything else for not awesome).
* Afterwards, the first person to vote was called up and told they were
* awesome. In this script, we call up the first person to vote that they're
* awesome and the first person to vote that they're not, in the hopes that
* the awesome person can help the not awesome person be awesome. Awesome,
<?php
class DB {
const DB_NAME = 'votes.sqlite';
protected $db;
function __construct() {
$this->db = new PDO('sqlite:'.self::DB_NAME);
}
@rahims
rahims / send.rb
Created May 4, 2011 06:42
Code to send an SMS using the Twilio API in Ruby. Written by Andrés Corvetto (not me, Rahim Sonawalla). Full blog post here: http://www.twilio.com/blog/2011/05/andres-corvetto-wins-our-twiliohardware-developer-contest.html
require 'twiliolib'
# Twilio REST API version
API_VERSION = '2010-04-01'
# Twilio AccountSid and AuthToken
ACCOUNT_SID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
ACCOUNT_TOKEN = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
FROM_ID = 'xxx-xxx-xxx';
@rahims
rahims / handle-payment.php
Created June 1, 2011 06:34
Sample code that shows how to send an SMS message using Twilio whenever a payment is posted to one of your FreshBooks invoices. Read the full tutorial here: http://www.twilio.com/blog/2011/06/how-to-create-sms-payment-notifications-for-freshbooks-using-tw
<?php
// The Twilio helper library. Get a copy here: http://www.twilio.com/docs/libraries/
require_once('twilio.php');
// Uses the FreshBooks helper library written by Milan Rukavina. Get a copy
// here: http://code.google.com/p/freshbooks-php-library/
require_once('FreshBooks/Payment.php');
require_once('FreshBooks/Invoice.php');
require_once('FreshBooks/HttpClient.php');
@rahims
rahims / handle-incoming-sms.php
Created July 22, 2011 20:55
Sample code on how to take an SMS and respond with an SMS based on what the person sent in
<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<Response>
<?php
// When an SMS comes into your Twilio phone number, Twilio passes
// the body of the SMS to your web app in the Body parameter.
$keyword = strtolower(trim($_REQUEST['Body']));
@rahims
rahims / get_notifications.php
Created July 28, 2011 21:18
Sample code that shows how to get all the notifications for your Twilio account
<?php
require 'Services/Twilio.php';
$ACCOUNT_SID = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$AUTH_TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$client = new Services_Twilio($ACCOUNT_SID, $AUTH_TOKEN);
try {
$notifications = $client->account->notifications->getIterator();
@rahims
rahims / .vimrc
Created January 13, 2012 01:49
My .vimrc file.
set encoding=utf-8
set nobackup
set noswapfile
set nocompatible
set autoindent
set showcmd
set visualbell
set ignorecase
set smartcase
set ruler