Google Voice Command Line Script
by trixter on Jul.28, 2009, under Telephony
UPDATE: Aug-20-2009 I added the ability to use a ~/.netrc file (if Net::Netrc is installed, if its not it will not use that
I also fixed the meta following problem. Fixed a couple other bugs – like the username/pass incorrect not reporting that error properly. You should upgrade to the new version now.
UPDATE: Sept-10-2009 I added the ability to send calls/sms messages to named contacts. It will use your google voice contact data, so if you want to use this feature you have to create a contact in google voice and use the nickname that you gave them. I changed the way arguments are passed, run the program for usage information. If you were already using this you will have to adjust how you call the program.
I wrote a perl script that lets you interface with your Google Voice account. You can place a call, cancel a call, and send a SMS message easily. This is ideal for people that want to send SMS messages for system alerts, or for other reasons.
In order to use this script you must first download it. Then edit the username, password and default number variables near the top of the script. Install any missing perl modules based on whatever distribution you have, if you run the script it will tell you what it is missing. Invalid args or no args will give you a help screen.
To send an SMS message to 12345678
./googlevoice.pl sms 12345678 this is a test sms message
To place a call to 12345678 (optionally set the ‘forwarding number’)
./googlevoice.pl call 12345678
./googlevoice.pl call 12345678 90123456
To cancel a call placed through the web (or this script)
./googlevoice.pl cancel
In the future I may access the HTTP based inbox so that you can periodically check for messages, and react to triggers on them. In order to do this you would access the following URLs. If anyone is bored I will gladly accept patches to my script to add this functionality.
Inbox XML:
https://www.google.com/voice/inbox/recent/inbox/
Starred Calls XML:
https://www.google.com/voice/inbox/recent/starred/
All Calls XML:
https://www.google.com/voice/inbox/recent/all/
Spam XML:
https://www.google.com/voice/inbox/recent/spam/
Trash XML:
https://www.google.com/voice/inbox/recent/trash/
Voicemail XML:
https://www.google.com/voice/inbox/recent/voicemail/
SMS XML:
https://www.google.com/voice/inbox/recent/sms/
Recorded Calls XML:
https://www.google.com/voice/inbox/recent/recorded/
Placed Calls XML:
https://www.google.com/voice/inbox/recent/placed/
Received Calls XML:
https://www.google.com/voice/inbox/recent/received/
Missed Calls XML:
https://www.google.com/voice/inbox/recent/missed/
55 Comments for this entry
4 Trackbacks / Pingbacks for this entry
-
VoIP IP Telephony
September 5th, 2009 on 3:50 amTalk Perl To Google Voice…
I found a perl script that can send SMS messages via Google Voice. So now I have this script on my experimental severs (and on a central watchdog server for permanent servers) that alerts me via SMS through Google Voice….
-
gDial Pro - Google Voice App - Page 46 - PreCentral Forums
September 10th, 2009 on 3:42 am[...] out what he's doing. Looks like ?pearl? and I'm not too familiar with that programming language. Google Voice Command Line Script | 0xdecafbad.com looks like he seems to have gotten it to work, now just to figure out how [...]
-
gDial Pro - Google Voice App - Page 47 - PreCentral Forums
September 10th, 2009 on 6:40 pm[...] out what he's doing. Looks like it's written in perl and I'm not too familiar with that language. Google Voice Command Line Script | 0xdecafbad.com looks like he seems to have gotten it to work, now just to figure out how I can probably [...]
-
Mark Waters (mark) 's status on Saturday, 03-Oct-09 16:08:53 CEST - microblog
October 3rd, 2009 on 6:09 am[...] Voice Command Line Script | 0xdecafbad.com – http://www.0xdecafbad.com/?p=87 #bash #command line #google #perl #shell a few seconds ago from [...]
February 4th, 2010 on 8:26 am
Hi Bret (or anyone who can help) –
I run a Little League and need a utility that will let me send Googel SMS messages to our membership. WOuld it be possible for someone to compile this into a simple .exe with parameters? I don’t know anything about Perl.
It would work something like this:
GV.exe SMS 2135551212 /U user@gmail.com /P P4$$w0rd “Games cancelled due to rain tomorrow”
I would then be able to view the status of each message in the normal Google Voice page.
please contact me at sdix00 (at) gmail dot com to discuss.
Thanks!!!
Steve
March 12th, 2010 on 6:52 pm
Hi Trixter, great work and congratulations for made this script =)….
I got the same 500 error, but I solved it adding phoneType=2 on this line 241 from :
$postdata = “outgoingNumber=$dst_number&forwardingNumber=$from_number&subscriberNumber=undefined&remember=0&_rnr_se=$rnr_se”;
to this:
$postdata = “outgoingNumber=$dst_number&forwardingNumber=$from_number&subscriberNumber=undefined&remember=0&_rnr_se=$rnr_se&phoneType=2″;
As mentioned in past post,
Success!..
April 27th, 2010 on 11:41 pm
I tried the code. It sends SMS perfectly.
I got the dreaded 500 error and so I made the change to add the call type, and cleared the error. It tells me that the call has been sent but the call never seems to connect
April 28th, 2010 on 12:04 am
Since writing this I noticed that there is a small issue, well I noticed two issues.
1. I do not detect the captcha when it happens. They occasionally do that, particularly if an IP has been flagged for some reason (noticed it when I tried it from the server)
2. You may only send calls from a registered phone now, no more can you use any arbitrary telephone number. It appears to send the call but it wont if you use any other number. It will also only let 1 call for each source/destination number per account. If you have 2 accounts and they both have the same registered phone number you can place two calls, one from each account, using the same source/destination numbers, but no more than 1 per account. Again, it will appear that it worked but it doesnt.
I also realized that google would be able to lower their web transaction costs if they would provide something like XML-RPC or something to interface with the account. It would also make my life easier
July 9th, 2010 on 6:47 am
Hi. I am hugely interested in getting this to work. I have installed Active State Perl, Windows 7 Pro, all modules etc.
I was originally getting errors but easily saw that I needed to install the WWW Mech. & plugin.
No, I run the script but I just keep getting the help screen every time.
I have substituted the variables in the script as:
my $username = “jvitz\@gmail.com”;
my $password = “myrealpasswordhere”;
my $default_number = “8435551212″;
When i try to run the script from the command promtp I am doing it as:
googlevoice.pl sms 8435551212 mytestmessage
when in hit ENTER, i get the following:
C:\RmDemo17\googlevoice.pl -c [-p phone] [-t type] [-f from] [args]
Commands:
sms -p
call -p
cancel
-t is only used if you specify a contact name for -p and not a number
So, I also tried it using the syntax shown as:
googlevoice.pl -c SMS -p 8435551212 mymessagetest
and I get the same help screen…
Any assistance would be greatly appreciated
jay