aboutsummaryrefslogtreecommitdiffstats
path: root/content/articles/conectar-xmpp-con-whatsapp-usando-yowsup-y-transwhat.en.md
blob: 5a6d9557a0f5af69987a6ca967aa820f6eab661d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Author: Megver83
Category: GNU/Linux
Date: 2017-05-18 06:35
Image: /2017/05/xmpp.png
Lang: en
Save_as: connect-xmpp-with-whatsapp-using-yowsup-and-transWhat/index.html
URL: connect-xmpp-with-whatsapp-using-yowsup-and-transWhat/
Slug: conectar-xmpp-con-whatsapp-usando-yowsup-y-transwhat
Tags: xmpp
Title: Connect XMPP with WhatsApp using yowsup and transWhat

Hasn't it happened to you that communication with your friends,
family, etc. is made difficult by the simple fact of not using
WhatsApp? Sure, it's a quick, easy, and cross-platform solution,
but it doesn't respect the freedoms and rights of users.
I know many people in the world of free software who have been
forced to install it because there is no other way to communicate
with those who need to do it (be it for work, school work, or
simply keep in touch with their loved ones). However,
with [yowsup][yowsupGIT] and [transWhat][transWhatGIT] that is over.
With both, you can chat with WhatsApp users, be in their groups
and more, using the best-known decentralized instant messaging
network: XMPP.

## What are yowsup and transWhat?

Yowsup is a python library that allows you to create applications
that use the WhatsApp service. Yowsup has been used to create an
unofficial WhatsApp Nokia N9 client through the
[Wazapp][WazappGIT] project that was in use by 200K + users,
as well as another completely unofficial client for Blackberry 10.
On the other hand, transWhat is a gateway to link between XMPP
and WhatsApp instant messaging networks.

## Brilliant! How do I start?

The basic requirements are:

- Have [pip][pipweb] installed.
- Create an XMPP account (if you don't have one) with support for
  the transWhat gateway. For example, [JabJab.de][jabjabsite]
- Have a mobile phone number.
- Have an advanced XMPP client, for example Gajim, with the XMPP
  account to be used configured.

## So, get to work!

From a terminal, install the yowsup2 package with pip as root.

    # pip install yowsup2

After you have installed it, make sure that in the file
/usr/lib/python3.6/site-packages/yowsup/env/env.py in
DEFAULT variable it says "Android" (including the quotes),
read this [comment][comment] from an issue from yowsup's
GitHub repository.

## Make account

To create an account with yowsup, you must run the following command:

```bash
$ yowsup-cli registration -E s40 -r sms -p <phone_number> -C <country_code> -m <country_mobile_code> -n <network_mobile_code>
```

So, as Jack the Ripper said, let's go part.

- `<phone_number>` it must be the complete telephone number, with the country code, except for the `+` sign
- `<country_code>` corresponds to the country code, if you do not know yours, see it [here][netlist].
- `<country_mobile_code>` It is the MCC that you can find [here][MCC].
- `<network_mobile_code>` It is the MNC that you can also find on the same page as `<country_mobile_code>`

If everything works, something like this should appear at the end of the command,
you should receive a text message with the code to register, similarly write:

```bash
$ yowsup-cli registration -E s40 -p <phone_number> -C <country_code> -m <country_mobile_code> -n <network_mobile_code> -R <sms_code>
```

Where `<sms_code>` corresponds to the code you received on your cell
phone.
The output of the command, near the end, you should get something like:

```bash
INFO:yowsup.common.http.warequest:b'{"status":"ok","login":"<phone_number>","type":"existing","pw":"FBmvgZs8UUbSX2ZHeVyxc7G7g4s=","expiration":4444444444.0,"kind":"free","price":"US$0.99","cost":"0.99","currency":"USD","price_expiration":1497967560}\n' status: b'ok' login: b'<phone_number>' pw: b'<password>' type: b'existing' expiration: 4444444444.0 kind: b'free' price: b'US$0.99' cost: b'0.99' currency: b'USD' price_expiration: 1497967560
```

What interests us here is what is blackened. It will show you your
phone number and password, which we will now use to connect XMPP
with WhatsApp. Note that the letters "b" and the apostrophes are
not blackened.

## Connecting XMPP and WhatsApp with transWhat

So now that we have the number and password, it's time for action.
If you use Gajim, go to **Actions>Discover services>using the
account jabjab.de** (or the one you use with transWhat support).
In the "Transport" section select "transWhat" and then click
"Subscribe", it will ask for the number and password that you
obtained with yowsup.

Ready! You already have a functional XMPP account with WhatsApp.
To add WhatsApp contacts you have to add them with the address
`<phone number>@domain.of.transport>`

**Note:**

`<telephone number>`: it must be the complete number but without the `+` sign,
the same as when you registered.

## To end

We hope this tutorial has helped you, share it with your friends, on social
networks and you have derived from this article if you wish, remember that
Conocimientos Libres is about that (o˘◡˘o)

I thank [trinux][u-trinux], who was the person who taught me how to
connect XMPP and WhatsApp.

[yowsupGIT]: https://github.com/tgalal/yowsup
[transWhatGIT]: https://github.com/stv0g/transwhat
[WazappGIT]: https://github.com/tgalal/wazapp
[pipweb]: https://pip.pypa.io/
[jabjabsite]: https://jabjab.de/
[comment]: https://github.com/tgalal/yowsup/issues/1952#issuecomment-284212268
[netlist]: http://www.ipipi.com/networkList.do
[MCC]: https://en.wikipedia.org/wiki/Mobile_country_code
[u-trinux]: https://trisquel.info/en/users/trinux