I am trying to write a sample python script that sends message to the listed whatsapp number. Upon little research, i found this python library "yowsup".
I am trying to register using the cli command written below:
yowsup-cli registration --requestcode sms --phone 9195******** --cc 91 --mcc 404 --mnc 86 -d
I am getting a bad token error while trying this command.
Searching for similar problems, here are some of the changes that i performed.
_USERAGENT_STRING = "WhatsApp/2.17.296 Android/4.4.2 Device/SAMSUNG-GT-N7100"
and
DEFAULT = "Android"
in
/usr/lib/python2.7/site-packages/yowsup/env/env.py file.
Here is the more detailed o/p/ using the debug option.
[root@localhost whatsapp]# yowsup-cli registration --requestcode sms --phone 91953********* --cc 91 --mcc 404 --mnc 86 -d
yowsup-cli v2.0.15
yowsup v2.5.2
Copyright (c) 2012-2016 Tarek Galal
http://www.openwhatsapp.org
This software is provided free of charge. Copying and redistribution is
encouraged.
If you appreciate this software and you would like to support future
development please consider donating:
http://openwhatsapp.org/yowsup/donate
DEBUG:yowsup.env.env:Env not set, setting it to android
DEBUG:yowsup.env.env:Current env changed to android
DEBUG:yowsup.common.http.warequest:{'Accept': 'text/json', 'User-Agent': 'WhatsApp/2.17.296 Android/4.4.2 Device/SAMSUNG-GT-N7100'}
DEBUG:yowsup.common.http.warequest:cc=91&in=9538944697&lc=GB&lg=en&sim_mcc=404&sim_mnc=086&mcc=404&mnc=086&method=sms&mistyped=6&network_radio_type=1&simnum=1&s=&copiedrc=1&hasinrc=1&rcmatch=1&pid=8476&rchash=8ba74b3230363264c788908e6010cb2a7c70a70f3ef7a1e4fea9085424024bab&anhash=%B0%04%C5V%F6%CA%D5%0C%C4%B5%28%90%7C%BBR%D8%F8F%D7%95&extexist=1&extstate=1&token=WhPO3Nlv52KJcgwnOfqBBFVAvw0%3D&id=%C4%0E%8B%22f%7FkX%FFIL%DD%9C%91%EE%89EXco
DEBUG:yowsup.common.http.warequest:Opening connection to v.whatsapp.net
DEBUG:yowsup.common.http.warequest:Sending GET request to /v2/code?cc=91&in=9538******&lc=GB&lg=en&sim_mcc=404&sim_mnc=086&mcc=404&mnc=086&method=sms&mistyped=6&network_radio_type=1&simnum=1&s=&copiedrc=1&hasinrc=1&rcmatch=1&pid=8476&rchash=8ba74b3230363264c788908e6010cb2a7c70a70f3ef7a1e4fea9085424024bab&anhash=%B0%04%C5V%F6%CA%D5%0C%C4%B5%28%90%7C%BBR%D8%F8F%D7%95&extexist=1&extstate=1&token=WhPO3Nlv52KJcgwnOfqBBFVAvw0%3D&id=%C4%0E%8B%22f%7FkX%FFIL%DD%9C%91%EE%89EXco
INFO:yowsup.common.http.warequest:{"login":"919538*******","status":"fail","reason":"bad_token"}
status: fail
reason: bad_token
login: 919538*******
Can someone suggest on the way forward?
On the env_android.py file, change the start of the class with this code:
then use the command: