2

I am working on an experiment where I am emailing/texting a large group of subjects a standard message and then receiving their responses via email/text. To add texting functionality I want to use pygooglevoice. When I use the Idle interface I'm able to login fine. But when I run an example script, it throws the "login error". I have already implemented the fix listed here (replacing the URL pygooglevoice accesses): Pygooglevoice login error.

The example script I'm running:

from googlevoice import Voice  
import sys  
import BeautifulSoup  



 def extractsms(htmlsms) :
     """
     extractsms  --  extract SMS messages from BeautifulSoup tree of Google Voice SMS HTML.

     Output is a list of dictionaries, one per message.
     """
     msgitems = []  # accum message items here
     #  Extract all conversations by searching for a DIV with an ID at top level.
     tree = BeautifulSoup.BeautifulSoup(htmlsms)  # parse HTML into tree
     conversations = tree.findAll("div",attrs={"id" : True},recursive=False)
     for conversation in conversations :
         #  For each conversation, extract each row, which is one SMS message.
         rows = conversation.findAll(attrs={"class" : "gc-message-sms-row"})
         for row in rows :  # for all rows
             #  For each row, which is one message, extract all the fields.
             msgitem = {"id" : conversation["id"]}  # tag this message with conversation ID
             spans = row.findAll("span",attrs={"class" : True}, recursive=False)
             for span in spans :  # for all spans in row
                 cl = span["class"].replace('gc-message-sms-', '')
                 msgitem[cl] = (" ".join(span.findAll(text=True))).strip()  # put text in dict
             msgitems.append(msgitem)  # add msg dictionary to list
     return msgitems

 voice = Voice() 
 voice.login('MY_GV_USERNAME','MY_GV_PASSWORD')

 voice.sms() for msg in extractsms(voice.sms.html):
 print str(msg)

The Error:

> File "build\bdist.win32\egg\googlevoice\voice.py", line 78, in login
>     raise LoginError LoginError

Alternatively, if someone has step-by-step advice for a clean uninstall of pygooglevoice for windows (to make sure I get all of the files), I would really appreciate it.

Community
  • 1
  • 1
  • did you read this already? https://code.google.com/p/pygooglevoice/issues/detail?id=60#c32 – Samuele Mattiuzzo Jun 27 '13 at 22:27
  • I just read it - I'm still getting the same issue. I had to adapt it a bit for windows cmd, but I think I got the best approximation - I copied all of the files in the 'bwpayne-pygooglevoice-auth-fix' folder into Python27 so that I could run "python setup.py install" from windows command prompt. – Nikki Schmidt Jun 27 '13 at 22:44

1 Answers1

1

I made a clone which currently works (at least for sending SMS messages): http://code.google.com/r/kkleidal-pygooglevoiceupdate/

The problem was that Google changed the login URL. In addition, I added a few params to the POST request which may have helped solve some issues it was running into with the POST request. Log in should work smoothly now.

Ken Leidal
  • 11
  • 1
  • fyi: I could not get this to work with Python 3.4.0. I ran your code thru Python's `2to3.py` converter and I had to make some changes to your regExs in `voice.py` but, I still get an error when trying to authenticate. See [here for my fork](https://code.google.com/r/aldass-pygooglevoice/source/list) of your code. – Al Dass May 04 '14 at 07:41