Since some weeks ago I used a Python library to use Twitter from Linux (I may make an entry about it) It also urged me the question of using WhatsApp from Linux. Today a friend sent me this article (spanish) and trying to replicate the examples I managed myself to get something working.
Everything is made through yowsup (see requirementes) from Tarek Galal which within few simple steps we get a working client.
For the following examples i used a spare SIM card and an old cellphone, first we must register the line.
First we create a plain text file which we will use to save our ‘profile’, in it it is important to highlight 3 fields.
#Complete phone number
The first elements will be obtained directly from the cellphone, the ‘password’ field is left in blank at first. Now we execute the following
./yowsup-cli -c [config file] –requestcode sms
It is important to notice that there is no need to do dis more than ONCE. Once done we will receive a sms like this:
WhatsApp code xxx-xxx
So now we execute
./yowsup-cli -c [config file] –register xxxxxx
#Es indistinto colocar o no el guión
which should return
Now we are currently registered, we have a password (pw) to complete the corresponding field in our text file and are ready to use the client.
For now im only using 3 functions send, listen, interactive.
Send is quite simple
./yowsup-cli -c [config file] -s [numero destinatario] “message”
Listen mode is as simple as send
./yowsup-cli -c [config file] -l
Here I want to stop to highlight something, if we execute this command as given, whoever sends us a message wont receive the “received notification” (doble check tick) and therefore every time we execute the command we will receive the “unread” messages. To avoid this we add the parameter -a (autoack), as we receive a new message the client will send the corresponding received ack.
The third and last function I tested is interactive which sort of combines send and listen. It is similar to the listen mode with the addition of having the possibility of replying the message. Note that with this mode we only receive/send message from/to a single contact.
./yowsup-cli -c [config file] -i [contact number]
Lets see 2 images from different endpoints, one in a pc other in a smartphone (spanish)
- View from console
- View from SmartPhone
Because of what I had previously mentioned I advise using the -a (autoack) y además el -k (keepalive) parameters. It is also strongly advised to read the given documentation in the repository.
The client alone comes with quite some functions, but doesnt implement all the available functions in the library; for example listed mode doesn’t fetch images. BUT given the fact that this is open source and that Tarek has done some nice code, it is not hard at all add the desired functionalities to the client.