Skip to content

Instantly share code, notes, and snippets.

@mikeymckay
Created April 2, 2010 16:09
Show Gist options
  • Save mikeymckay/353315 to your computer and use it in GitHub Desktop.
Save mikeymckay/353315 to your computer and use it in GitHub Desktop.
def recent
@curb.url = "https://www.google.com/voice/inbox/recent/"
@curb.http_get
doc = Nokogiri::XML::Document.parse(@curb.body_str)
data = doc.xpath('/response/json').first.text
html = Nokogiri::HTML::DocumentFragment.parse(doc.to_html)
json = JSON.parse(data)
# Format for messages is [id, {attributes}]
json['messages'].map do |conversation|
next if conversation[1]['type'].to_i != GOOGLE_VOICE_SMS_TYPE
html.css('div.gc-message-sms-row').map do |row|
next if row.css('span.gc-message-sms-from').inner_html.strip! =~ /Me:/
text = row.css('span.gc-message-sms-text').inner_html
time = row.css('span.gc-message-sms-time').inner_html
from = conversation[1]['phoneNumber']
{
:id => Digest::SHA1.hexdigest(conversation[0]+text+from)
:text => text,
:time => time,
:from => from
}
end
end.flatten.compact
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment