python

How to use YOWSUP (The python WhatsApp library) in ubuntu

Yowsup is a python library that allows you to login and use the WhatsApp service and provides you with all capabilities of an official WhatsApp client, allowing you to create a full-fledged custom WhatsApp client.

yowsup_block

Installation

sudo apt-get update

Prepare the system with the necessary components to Yowsup

sudo apt-get install python-dateutil
sudo apt-get install python-setuptools
sudo apt-get install python-dev
sudo apt-get install libevent-dev
sudo apt-get install ncurses-dev

I’m available for hire!

This is my email link: iamjagjeetubhi@gmail.com

Download the library with the command

git clone git://github.com/tgalal/yowsup.git

Navigate to the folder

cd yowsup

and install the library with the command

sudo python setup.py install

Registration

After installing the library we have to register the device to use WhatsApp. Yowsup comes with a cross platform command-line frontend called yowsup-cli. It provides you with the options of registration, and provides a few demos such as a command line client.

    • First of all create a file vim dexMD5.py
    • Now paste the code from this file.
    • Then save and quit the file.

I’m available for hire!

This is my email link: iamjagjeetubhi@gmail.com

  • Now, Download latest version of WhatsApp from here
  • Copy the Downloaded WhatsApp.apk to current directory.
  • Run the command python dexMD5.py WhatsApp.apk
  • You will get the output like
    Version: 2.17.344
    ClassesDex: OxVSHnBDYNBZmSiYzwF9+A==
  • You have to write that in
    yowsup/env/env_android.py

    (replacing _MD5_CLASSES and _VERSION vars) then run:

  • python setup.py build
  • python setup.py install

WhatsApp registration involves 2 steps. First you need to request a registration code. And then you resume the registration with code you got.

Request a code with command

python yowsup-cli registration --requestcode sms --phone 91xxxxxxxxxx --cc 91 --mcc 222 --mnc 10 -E android

Please add country code as well before mobile no.

Replace with your data ,

cc is your country code in this example 91 is for India,

mcc is Mobile Country Code check your here

mnc is Mobile Network Code check your here

You should receive on your phone a sms message with a code like xxx-xxx

Send a message to request registration with this command, (replace xxx-xxx with code you received)

python yowsup-cli registration --register xxx-xxx --phone 91xxxxxxxxxx --cc 91 -E android

If all goes well, we should get a message like this

status: ok
kind: free
pw: xxxxxxxxxxxxxxxxxx= #this is the password
price: ₹ 55
price_expiration: 1509040085
currency: INR
cost: 55.00
expiration: 4444444444.0
login: 91xxxxxxxxxx
type: new

Create a file to save your credentials in current directory

I’m available for hire!

This is my email link: iamjagjeetubhi@gmail.com

sudo vim config

with this content

## Actual config starts below ##
  cc=91 #if not specified it will be autodetected
  phone=91xxxxxxxxxx
  password=xxxxxxxxxxxxxxx=

Ok, we’re ready for the test,

I’m available for hire!

This is my email link: iamjagjeetubhi@gmail.com

yowsup-cli demos --yowsup --config config

You can see Yowsup prompt

If type “/help” you can see all available commands

First use the ‘/L’ command for login; to send a message type

/message send 91xxxxxxxxxx "This is a message sent from Command line"

replace xxx with the recipient number

If you respond with a message it will be displayed.

Thanks. 🙂

Advertisements

46 thoughts on “How to use YOWSUP (The python WhatsApp library) in ubuntu”

  1. connected]:/message broadcast 91xxxxxxxxxx “hi”
    [connected]:
    Sent: 1507379830-4
    I am not getting any error and not receive the message

    Like

  2. Hi , i installed it and tried your advices , with successful registration , but when i use the command , yowsup-cli demos –yowsup –config config
    where the config file supplied with my mobile and password , but it still showed ,

    [offline] : /L
    general: Disconnected: Connection Closed

    any further advice ? Thanks.

    Like

  3. i need help to install yowsup api,
    if any can help me intall and teach me how to use i ill pay for this help
    thanks
    whatsapp +923218355022

    Like

  4. Hi,

    Thank you for providing such a clear demonstration.

    I have managed to register (android) however when using yowsup-cli demos I get

    “`general: Login Failed, reason: not-authorized
    Auth Error, reason not-authorized

    or

    “`general: Login Failed, reason: not-authorized
    DEBUG:yowsup.layers.network.layer:Disconnected, reason: Authentication Failure
    Auth Error, reason not-authorized
    “`

    I don’t think I am banned because if I download whatsapp on the handset I registered I can use it to send/receive just fine.

    In env_android.py I have changed _MD5_CLASSES & _VERSION, did you change _KEY too?
    Also in env.py DEFAULT = Android.

    Any suggestions?
    Thanks in advance.

    Like

  5. hm… got strange error on python dexMD5.py WhatsApp.apk:

    Version:
    credBlocks:PAY: IndiaUPIAppActivity onLibraryResult for credentials: 4PAY: IndiaUPIAppActivity onLibraryResult got error: 7PAY: IndiaUPIAppActivity onLibraryResult for resend otp PAY: startShowPinFlow at count: max: 3; showErrorAndFinish#PAY: onRegisterApp got registered: ; showErrorAndFinishinitial#PAY: onGetChallenge got challenge:

    Like

  6. Hi, after I run command yowsup-cli registration –requestcode sms -p 6013375xxxx –cc 60 –mcc 502 –mnc 13 -E android -d, I’m getting error bad_token. Can you help please?

    Like

    1. My mistake. I can get the code and successfully registered. But when I try the next step to login, I get this error;

      [offline]:/L
      general: Login Failed, reason: not-authorized
      Auth Error, reason not-authorized

      Like

  7. Hi, I have the same problem of Azizyaakup.
    [offline]:/L
    general: Login Failed, reason: not-authorized
    Auth Error, reason not-authorized
    Can you help me, please?

    Like

  8. Thanks a lot for sharing this! Can you please explain how does this method with downloading apk file is different from other solutions like https://github.com/colonyhq/yowsup which do not require apk. Is it better from banning perspective? Would appreciate detailed explanatation since trying to get into field deeper and bans are very critical for many. Thanks in advance

    Like

  9. Hello, I followed all the steps but returned the following:
    yowsup marcus$ python yowsup-cli registration –requestcode sms –phone 551143496189 –cc 55 –mcc 724 –mnc 06 -E android
    yowsup-cli v2.0.15
    yowsup v2.5.7

    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

    INFO:yowsup.common.http.warequest:{“login”:”551143496189″,”status”:”fail”,”reason”:”bad_param”,”param”:”number”}

    status: fail
    param: number
    reason: bad_param
    login: 551143496189

    Whatsapp version:
    Version: 2.18.62
    ClassesDex: KAtYkYa0lEUyKqfhXtmGhw==

    Where did I go wrong?

    Thanks if you can help me.

    Like

  10. Hi Jagjeet,
    Awesome tutorial and effort. I have implemented the solution but facing an issue. I’m able to send message to only one contact whenever I try to send message to other contact it Yowsup-cli showing help command.

    I’m also getting below error while executing /L – login command and my terminal hangs(using python 2.7)

    [offline]:/L
    Auth: Logged in!
    [connected]:WARNING:axolotl.sessionbuilder:We’ve already setup a session for this V3 message, letting bundled message fall through…
    Traceback (most recent call last):
    File “/usr/local/bin/yowsup-cli”, line 4, in
    __import__(‘pkg_resources’).run_script(‘yowsup2==2.5.7’, ‘yowsup-cli’)
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py”, line 742, in run_script
    self.require(requires)[0].run_script(script_name, ns)
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py”, line 1667, in run_script
    exec(code, namespace, namespace)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/EGG-INFO/scripts/yowsup-cli”, line 368, in
    if not parser.process():
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/EGG-INFO/scripts/yowsup-cli”, line 268, in process
    self.startCmdline()
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/EGG-INFO/scripts/yowsup-cli”, line 297, in startCmdline
    stack.start()
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/demos/cli/stack.py”, line 26, in start
    self.stack.loop(timeout = 0.5, discrete = 0.5)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/stacks/yowstack.py”, line 189, in loop
    asyncore.loop(*args, **kwargs)
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py”, line 216, in loop
    poll_fun(timeout, map)
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py”, line 156, in poll
    read(obj)
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py”, line 87, in read
    obj.handle_error()
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py”, line 83, in read
    obj.handle_read_event()
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py”, line 449, in handle_read_event
    self.handle_read()
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/network/layer.py”, line 102, in handle_read
    self.receive(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/network/layer.py”, line 110, in receive
    self.toUpper(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/__init__.py”, line 79, in toUpper
    self.__upper.receive(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/stanzaregulator/layer.py”, line 29, in receive
    self.processReceived()
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/stanzaregulator/layer.py”, line 52, in processReceived
    self.processReceived()
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/stanzaregulator/layer.py”, line 49, in processReceived
    self.toUpper(oneMessageData)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/__init__.py”, line 79, in toUpper
    self.__upper.receive(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/auth/layer_crypt.py”, line 65, in receive
    self.toUpper(payload)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/__init__.py”, line 79, in toUpper
    self.__upper.receive(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/coder/layer.py”, line 35, in receive
    self.toUpper(node)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/__init__.py”, line 79, in toUpper
    self.__upper.receive(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/logger/layer.py”, line 14, in receive
    self.toUpper(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/__init__.py”, line 79, in toUpper
    self.__upper.receive(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/layer_control.py”, line 44, in receive
    self.toUpper(protocolTreeNode)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/__init__.py”, line 79, in toUpper
    self.__upper.receive(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/__init__.py”, line 194, in receive
    s.receive(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/layer_receive.py”, line 41, in receive
    self.onMessage(protocolTreeNode)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/layer_receive.py”, line 74, in onMessage
    self.handleEncMessage(protocolTreeNode)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/layer_receive.py”, line 90, in handleEncMessage
    self.handleSenderKeyMessage(node)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/layer_receive.py”, line 159, in handleSenderKeyMessage
    self.parseAndHandleMessageProto(encMessageProtocolEntity, plaintext)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/layer_receive.py”, line 188, in parseAndHandleMessageProto
    self.handleConversationMessage(node, m.conversation)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/layer_receive.py”, line 217, in handleConversationMessage
    self.toUpper(messageNode)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/__init__.py”, line 79, in toUpper
    self.__upper.receive(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/__init__.py”, line 194, in receive
    s.receive(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/__init__.py”, line 130, in receive
    recv(node)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/protocol_messages/layer.py”, line 21, in recvMessageStanza
    self.toUpper(entity)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/__init__.py”, line 79, in toUpper
    self.__upper.receive(data)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/interface/interface.py”, line 80, in receive
    self.entity_callbacks[entityType](entity)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/demos/cli/layer.py”, line 512, in onMessage
    MESSAGE_ID = message.getId()
    UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-6: ordinal not in range(128)

    Thanks

    Like

  11. I have tried with python 3.6. I’m getting below error while login

    [offline]:/L
    general: Login Failed, reason: not-authorized
    Auth Error, reason not-authorized

    I’m on mac system
    Please help
    Thanks

    Like

  12. hello,

    I have install yowsup and registered my mobile no by mistake i removed yowsup directory. so i doing same process again at that time i am not able to register my same mobile
    it gives below response

    INFO:yowsup.common.http.warequest:b'{“status”:”fail”,”reason”:”blocked”,”login”:”91xxxxxxxxxx”}\n’
    status: b’fail’
    reason: b’blocked’

    please help me

    i have to re-registered mobile no again ?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s