domingo, 17 de febrero de 2013

My raspberry Pi sending whatsapps

1/ Create a phone number using http://www.fonyou.com/   (not included in this tutorial)
2/ Register a fonyou number to can send a whatsapp (here is where i found with more problems), so, i will explain in detail.

I have used : https://github.com/tgalal/yowsup   (the common line help is describe in https://github.com/tgalal/yowsup/wiki/yowsup-cli#wiki-config)

Download
wget https://github.com/tgalal/yowsup/archive/master.zip
unzip master.zip
cd yowsup-master/src/

In the webpage of yowsup, you can see that is required python-dateutil (in my case, i had to install)
apt-get install python-dateutil

Edit the the configutation file:
nano config.example

Change the attributes "cc" and "phone" with your data.
cc=34
phone=346XXXXXXX
id=
password=

The whatsapp register phase is in 2 steps: 
1/Register phase. It could be do by sms or by voice. 
1.1. sms: I tried with the sms but never arrived to the fonyou phone. (reading by inet, looks like they dont support whatsapp)
python yowsup-cli -c config.example --requestcode sms


1.2. voice: Finally, i use this option. After did the request, you will receive a call in your phone associate to fonyou phone, and a record will repeat the activation code 
python yowsup-cli -c config.example --requestcode voice 

2/ Activation phase. In this phase, whatsapp should return your password 
python yowsup-cli -c config.example --register [CODE] 

Doing this, i have found this issue:

Traceback (most recent call last):
  File "yowsup-cli", line 283, in <module>
    print resultToString(result)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 67: ordinal not in range(128)


Doing some investigation by inet, looks like the EURO can not print to screen and could be fixed if you set in the  encoding file of phyton .. really, it's not necesary to do anything, becouse, it could be use some workaround to see the password. Just retry the same line, but, adding -d to show the request/respond
 

xbian@xbian:~/yowsup/yowsup-master/src# python yowsup-cli -c config.example --register [CODE] -d
GET
{'Accept': 'text/json', 'User-Agent': 'WhatsApp/2.3.53 S40Version/14.26 Device/Nokia302'}
cc=34&in=6XXXXXXXX&id=XXXXXX&code=[CODE]
Opening connection to v.whatsapp.net
Requesting /v2/register?cc=34&in=6XXXXX&id=XXXXXXX&code=XXXXXX
WARegRequest: {"status":"ok","login":"346XXXXXXX","pw":"aadsdasadasdaasdaadasd=","type":"existing","expiration":XXXXXXXX,"kind":"free","price":"0,89 \u20ac","cost":"0.89","currency":"EUR","price_expiration":XXXXX}

Traceback (most recent call last):
  File "yowsup-cli", line 283, in <module>
    print resultToString(result)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 67: ordinal not in range(128)




So, here, the import is the value for the key "pw" (in the example, correspond with 
aadsdasadasdaasdaadasd=)

Edit the the configutation file:
nano config.example

Include your  pwd in the config.example
cc=34
phone=346XXXXXXX
id=
password=aadsdasadasdaasdaadasd=

And send the message to the phone that you want (remenber the country code)
python yowsup-cli -c config.example -s 346000000 "hello world"


2 comentarios:

  1. hello, what does the CC represent? thanks

    ResponderEliminar
    Respuestas
    1. CC represent the country code to call your phone. See:
      http://en.wikipedia.org/wiki/List_of_country_calling_codes

      i.e: In case of Spain 34

      Eliminar