From 910f6b9c820ceee7c589f368db3e6d7bcbe07d27 Mon Sep 17 00:00:00 2001 From: Will Hodges Date: Fri, 6 Nov 2015 10:01:00 -0500 Subject: [PATCH] Create extractsms Created an example function to get all the messages from the user's inbox. --- extractsms | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 extractsms diff --git a/extractsms b/extractsms new file mode 100644 index 0000000..79c6027 --- /dev/null +++ b/extractsms @@ -0,0 +1,26 @@ +require 'googlevoiceapi' +require 'json' +require 'nokogiri' +require 'rubygems' + +$api = GoogleVoice::Api.new("hodgeswt", "Aragorn1234") +def getSms() + page = Nokogiri::HTML($api.inbox_xml()) + msg = page.xpath("//span[@class='gc-message-sms-text']") + msgs = [] + msg.each do |msgMsg| + msgs << msgMsg.text + end + from = page.xpath("//span[@class='gc-message-sms-from']") + froms = [] + from.each do |fromMsg| + froms << fromMsg.text.gsub('\n', '') + end + smss = [] + i = 0 + while i < froms.length do + smss << [froms[i].gsub('\n', ''), msgs[i]] + i = i + 1 + end + return smss +end