0xdecafbad.com

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

  • Steve

    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

  • N3o

    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!..

  • Magic

    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

  • trixter

    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 :)

  • jay

    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

4 Trackbacks / Pingbacks for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...