User Tools

Site Tools


linux:whatsapp

This is an old revision of the document!


Send Whatsapps from linux (just another recipe)

<WRAP center round alert 60%> Deprecated!!! With the latest update of Whatsapp, I'm afraid these libraries are outdated too. If you want to send notification messages to your phone, I'd rather recomend using Telegram instead of whatsapp. Whatsapp have shown its determination to keep their API secret. </WRAP>

I've found two libraries to sends whatsapps from Linux (and Windows, too):

I've found that the yowsup library works very well in the process of registering a telephone number and getting the necessary password. The problem of this library now is that it's too complicated to send a single message (I've tried it hard, I promise).

On the other hand WhatsAPI is simple to use, but –as far as I know–, the registration does not work.

So, I decided to mix the best of two worlds and get a process more or less simple to send a simple message.

Register your phone number with yowsup

Download the code:

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

Start the registration by invoking:

yowsup-cli registration --requestcode sms --phone 49XXXXXXXX

Then, an sms will be sent to the phone in question. After this, confirm the registration by invoking:

yowsup-cli registration --register 123456 --phone 49XXXXXXXX

After this, you will get a phone number and a password. With this, you can use WhatsAPI to send your messages.

Send a message with WhatsAPI

Download the source code of WhatsAPI:

git clone https://github.com/venomous0x/WhatsAPI.git

I've created a simple php program that just sends a message and exits:

<?php
set_time_limit(10);
require_once '../src/whatsprot.class.php';
//Change to your time zone
date_default_timezone_set('Europe/Madrid');
 
///////////////////////CONFIGURATION///////////////////////
//////////////////////////////////////////////////////////
$username = "49XXXXXXXXX"; // Telephone number including the country code
$password = "PUT THE PASSWORD HERE"; // A server generated Password
$identity = ""; // Obtained during registration with this API or using MissVeno
$nickname = ""; // This is the username (or nickname) d
$target = $argv[1]; // Destination telephone number including the country code 
$debug = false; // Set this to true, to see debug mode.
///////////////////////////////////////////////////////////
 
$w = new WhatsProt($username, $identity, $nickname, $debug);
$w->connect();
 
// Now loginWithPassword function sends Nickname and (Available) Presence
$w->loginWithPassword($password);
 
$w->sendMessage($target, argv[2]);
 
?>

And you can call by the command line:

$ php5 49DESTINATIONPHONE "this is a test message"

and that's it: sending whatsapp from a computer, direct and simple.

linux/whatsapp.1434489687.txt.gz · Last modified: 2022/12/02 22:02 (external edit)