Pygoogle语音未登录

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (18)

谷歌刚刚更新了他们的谷歌语音平台。这似乎与我的googlevoice登录停止工作直接相关。

I have tried the following:

  • allowing captcha as suggested here (pygooglevoice-login-error)
  • Adapting a 2.7 solution here with no luck Python Google Voice
  • Logging out of my session that is voice.logout()
  • 卸载pygooglevoice并重新安装。
  • Tried a different google voice account.

This code was working perfectly up until the google voice website makeover. python 3.5.2 windows Server2012R2

from googlevoice import Voice
from googlevoice.util import input


voice = Voice()
voice.login(email='email@gmail.com', passwd='mypassword')


def sendText(phoneNumber,text):
    try:
        voice.send_sms(phoneNumber, text)
    except Exception:
        pass

sendText(phoneNumber=[aaabbbcccc],text="Hello from Google Voice!")

voice.logout()

Error Log:

Traceback (most recent call last):
  File voice.py, line 95, in login
    assert self.special
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  line 7, in <module>
    voice.login(email='********', passwd='*******')
  File voice.py, line 97, in login
    raise LoginError
googlevoice.util.LoginError
提问于
用户回答回答于

Per Ward Mundy:

新版本的gvoice命令行短信文本消息可用,修复后可与Google新的现代化“AngularJS”gvoice Web界面配合使用。如果有人想知道,这是一个很小的改变,让它工作。将这些命令粘贴到shell中进行升级:

cd ~

git clone https://github.com/pettazz/pygooglevoice

cd pygooglevoice

python setup.py install

cp -p bin/gvoice /usr/bin/.

pip install --upgrade BeautifulSoup

https://pbxinaflash.com/community/threads/sms-with-google-voice-is-back-again.19717/page-2#post-129617

用户回答回答于

我有同样的问题。它看起来像正在发送的页面背面是一个显着的不同,使用Javascript / AJAX不是什么之前发送的解决方案。

我一直在搞乱它并跟踪它丢失之前包含的“特殊”会话令牌。PyGoogleVoice正在搜索从谷歌发回的HTML页面中的字符串文字“_rnr_se”来刮取会话值。找不到该字符串,这会导致它认为登录失败。据我所知,PGV需要该令牌才能使url / function回调模仿web客户端。

现在有一个javascript函数正在检索该变量,而不是将其传回,而是在HTML页面中进行硬编码。

gc.net.XhrManager = function(xsrfToken, notification, loadNotification) {
  goog.events.EventTarget.call(this);
  this.xsrfToken_ = xsrfToken;
  this.notification_ = notification;
  this.loadNotification_ = loadNotification;
  this.logger_ = goog.debug.Logger.getLogger("gc.Xhr");
  this.xhrManager_ = new goog.net.XhrManager(0);
  this.activeRequests_ = new goog.structs.Map;
  this.eventHandler_ = new goog.events.EventHandler(this);
  this.eventHandler_.listen(this.xhrManager_, goog.net.EventType.SUCCESS, this.onRequestSuccess_);
  this.eventHandler_.listen(this.xhrManager_, goog.net.EventType.ERROR, this.onRequestError_);
};  

然后在进行调用时,它使用的值如下:

gc.net.XhrManager.prototype.sendPost = function(id, url, queryData, opt_successCallback, opt_errorCallback) {
  this.sendAnalyticsEvent_(url, queryData);
  id = goog.string.buildString(id, this.idGenerator_.getNextUniqueId());
  if (goog.isDefAndNotNull(queryData) && !(queryData instanceof goog.Uri.QueryData)) {
    throw Error("queryData parameter must be of type goog.Uri.QueryData");
  }
  var uri = new goog.Uri(url), completeQueryData = queryData || new goog.Uri.QueryData;
  completeQueryData.set("_rnr_se", this.xsrfToken_);
  this.activeRequests_.set(id, {queryData:completeQueryData, onSuccess:opt_successCallback, onError:opt_errorCallback});
  this.xhrManager_.send(id, uri.toString(), "POST", completeQueryData.toString());
};

我想我会分享我的发现,以便其他人可以帮助修改新代码并找出如何检索和与这个新版本交互。一旦我们找到捕获xsrfToken或_rnr_se值的新方法,它可能不会太遥远。

我现在的时间有点短暂,但我很想再次开始工作。这可能是一个搞乱使用firebug等问题来观察会话如何通过javascript在浏览器中启动并让PGV模仿新的URL等。

扫码关注云+社区

领取腾讯云代金券