@Nico111 After fiddling around I got yowsup 2.5.7 up and running (see below), BUT after the first message it seems that my number got banned. After getting back to the yowsup Wiki I found this note:
If you use the yowsup-cli command for registration of a new number, you run the risk of being black-listed by WhatsApp after sending your first message. To avoid this, register using an actual mobile device with WhatsApp installed, send a few messages, and then to be safe wait for 12-24 hours before removing your WhatsApp installation and registering the same number using the yowsup-cli as above. See issue 2482 for reference.
for my number it’s to late, but maybe someone else could verify that trick.
Pre-requisite: You need a mobile number, which is not yet registered with WhatsApp, e.g. a prepaid SIM. This is only required once, the SIM is not relevant anymore, but shouldn’t be used in a smartphone with WhatsApp at any time.
1. Install required packages:
Preperation on Linux
sudo apt-get update
sudo apt-get install libncurses5-dev
Preperation on Mac (needs Homwbrew)
brew install wget --with-libressl
brew install ncurses
Install Python modules:
pip install --upgrade pip
pip install argparse
pip install python-dateutil
pip install --upgrade readline
pip install protobuf
pip install pycrypto
pip install python-axolotl-curve25519
pip install --upgrade pillow
go to the directory where you want to download and build yowsup
wget https://github.com/tgalal/yowsup/archive/master.zip
unzip master.zip
cd yowsup-master/
don’t run setup.py yet!
2. Updating WhatsApp version
You need to update the WhatsApp version and a key, otherwise you get error “old_version”!
You find suitable settings under https://coderus.openrepos.net/whitesoft/whatsapp_scratch
{"a": "HVpGIJI3MRi3wZmsvjJDqw==", "b": "PdA2DJyKoUrwLw1Bg6EIhzh502dF9noR9uFCllGk", "c":"1478194306452L", "d":"**2.18.355**", "e":"2.16.12", "f":"2.11.634", "g":"PdA2DJyKoUrwLw1Bg6EIhzh502dF9noR9uFCllGk", "h":"1478194472015L", "i":"PdA2DJyKoUrwLw1Bg6EIhzh502dF9noR9uFCllGk", "j":"1478194472015L"}
Use parameter a and d and update the file yowsup/env/env_android.py
nano yowsup/env/env_android.py
and change the lines
_MD5_CLASSES = "<hash>"
_VERSION = "<version>"
for example:
_MD5_CLASSES = "HVpGIJI3MRi3wZmsvjJDqw=="
_VERSION = "2.18.355"
Now build and install yowsup
Linux:
python ./setup.py install
MacOS:
python2 ./setup.py install
3. WhatsApp registration
You need to lookup Mobile Country Code (MCC), the Mobile Network Code (MNC) and the normal Country Code (CC) you want to use:
Open https://en.wikipedia.org/wiki/Mobile_country_code and look for MCC and MNC. Those identify the mobile network you are using, e.g. MCC=262 for Germany and MNC=1 for Telekom, MNC=2 for VodafoneDE etc.
Run the WhatsApp registration:
yowsup-cli registration -d -E android -m <MCC> -n <MNC> -p <phone number> -C <country code> -r sms
Example: Germany (MCC=262, Country Code=49) and T-Mobile (MNC=1), phone number 491711234567
yowsup-cli registration -d -E android -m 262 -n 1 -p 491711234567 -C 49 -r sms
Make sure to prefix your phone number also with the country code, in this case 49xxxx. Do not include the 0 for the phone number, e.g. 01711234567 becomes 491711234567.
As a result you receive a SMS on your mobile phone. You need the 6 digit registration code in format XXX-XXX sent by WhatsApp. SMS text will be something like:
Your WhatsApp code: XXX-XXX
...
Registration will be completed with the following command:
yowsup-cli registration -d -E android -p <CC><phone number without 0> -C <CC> -R <Registration Code>
for example: yowsup-cli registration -d -E android -p 491711234567 -C 49 -R 123-456
Now you should receive a result like this one:
status: ok
kind: free
pw: <password>
price: $0.99
price_expiration: 1543012826
currency: USD
cost: 0.99
expiration: 4444444444.0
login: <phone number>
Generate some keys with the following command:
./yowsup-cli demos -l "491711234567:XXXXXX0uB6IMp9spB9FqedKFak=" -y
This opens the yowsup command line interface.
Do a Quick Login by entering "/L<return>"
This should result in a response like:
INFO:yowsup.layers.axolotl.layer_control:Axolotl layer is generating keys
Auth: Logged in!
general: Disconnected: Requested
4. Sending messages
Finally you are able to send messages.
yowsup-cli demos -l "<originating number>:<password from previous step>" -s <destination number> "<message>"
example:
yowsup-cli demos -l "491711234567: XXXXXX0uB6IMp9spB9FqedKFak =" -s 491727654321 "Welcome to openHAB"
You should receive the message in WhatsApp on the target phone