我正在为whatsapp工作,我正在使用Yowsup。 当我使用Yowsup Cli客户端时,我设法登录whatsapp帐户并从中发送和接收消息。 当我尝试使用以下脚本时,它会返回" Auth Failed!"。
import sys
import os
import logging
import time
import shutil
import Queue
from collections import defaultdict
from Yowsup.Common.debugger import Debugger
from Yowsup.connectionmanager import YowsupConnectionManager
from py_utils import logutils
from py_utils import executable_utils
from py_utils import exception_utils
from py_utils.cli_utils import actions_handler
COUNTRY_CODE = "COUNTRY_NUM"
PHONE_NUMBER = "MYNUMBER"
# IDENTITY = ""
PASSWORD = 'MY_PASS_WORD'
LOGIN = COUNTRY_CODE + PHONE_NUMBER
import argparse, sys, os, csv
from Yowsup.Common.utilities import Utilities
from Yowsup.Common.debugger import Debugger
from Yowsup.Common.constants import Constants
from Yowsup.Contacts.contacts import WAContactsSyncRequest
from Yowsup.connectionmanager import YowsupConnectionManager
import threading,time, base64
########## DO NOT COMMIT THIS FILE WITH YOUR CREDENTIALS ###########
#.....................WhatsApp Account Config.......................
nickname = "lamaaaaaaa"
username = LOGIN
password = PASSWORD
id = "" # Not required
#....................................................................
# Degug is False by default if you add -d you will set it to True
Debugger.enabled = True if '-d' in sys.argv else False
password = base64.b64decode(bytes(password.encode('utf-8')))
def login(username, password):
print "[] Logging in as %s (%s)\n" % (nickname, username)
methodsInterface.call("auth_login", (username, password))
def onAuthSuccess(username):
print("Authed!!\n\n")
methodsInterface.call("ready")
methodsInterface.call("presence_sendAvailableForChat", (nickname,))
def onAuthFailed(username, err):
print("Auth Failed!")
########################### BIND EVENTS #############################
connectionManager = YowsupConnectionManager()
signalsInterface = connectionManager.getSignalsInterface()
methodsInterface = connectionManager.getMethodsInterface()
connectionManager.setAutoPong(True)
signalsInterface.registerListener("auth_success", onAuthSuccess)
signalsInterface.registerListener("auth_fail", onAuthFailed)
#####################################################################
login(username, password)
答案 0 :(得分:2)
问题是需要更新访问令牌。 在Yowsup包中有comon \ constans.py 需要将tokanData更新为:
tokenData = {
"v": "2.12.53",
"r": "S40-2.12.53",
"u": "WhatsApp/2.12.53 S40Version/14.26 Device/Nokia302",
"t": "PdA2DJyKoUrwLw1Bg6EIhzh502dF9noR9uFCllGk1416435341393{phone}",
"d": "Nokia302"
# "v": "2.12.15",
# "r": "S40-2.12.15",
# "u": "WhatsApp/2.12.15 S40Version/14.26 Device/Nokia302",
# "t": "PdA2DJyKoUrwLw1Bg6EIhzh502dF9noR9uFCllGk1391039105258{phone}",
# "d": "Nokia302"
}
你可以看到我拥有的和我需要使用的东西之间的区别