Created
December 15, 2009 06:21
-
-
Save shayne/256735 to your computer and use it in GitHub Desktop.
A quick interface to the Google Voice using an undocumented API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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