Skip to content

Instantly share code, notes, and snippets.

@shayne
Created December 15, 2009 06:21
Show Gist options
  • Save shayne/256735 to your computer and use it in GitHub Desktop.
Save shayne/256735 to your computer and use it in GitHub Desktop.
A quick interface to the Google Voice using an undocumented API
require 'rest_client'
class GVoice < Struct.new :e, :p
def initialize(*args, &block)
super; instance_eval &block if block_given?
end
def send_sms(number, text)
post 'sms/send', :phoneNumber => number, :text => text, :_rnr_se => get[/'_rnr_se': '([^']+)'/, 1]
end
def method_missing(s, *a) super unless RestClient.respond_to? s
RestClient.send(s, "https://www.google.com/voice/%s?auth=%s" % [a.first,
@auth ||= RestClient.post('https://www.google.com/accounts/ClientLogin',
{:service => 'grandcentral', :Email => e, :Passwd => p})[/Auth=([^\n]+)/,1]], *a[1..-1])
end
end
GVoice.new("[email protected]", "password") do
send_sms 5555551234, Time.now
puts get 'inbox/recent/sms'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment