venomous0x / WhatsAPI

Interface to WhatsApp Messenger
2.59k stars 2.14k forks source link

Not able to send messages #203

Open ghost opened 11 years ago

ghost commented 11 years ago

I'm able to login using my android phone's credentials, but when i try to send a message to my friend whose using an iPhone, he is not receiving any messages.

My code :

!/usr/bin/php

<?php require "../src/php/whatsprot.class.php"; function fgets_u($pStdn) { $pArr = array($pStdn);

if (false === ($num_changed_streams = stream_select($pArr, $write = NULL, $except = NULL, 0))) {
    print("\$ 001 Socket Error : UNABLE TO WATCH STDIN.\n");
    return FALSE;
} elseif ($num_changed_streams > 0) {
    return trim(fgets($pStdn, 1024));
}

}

$nickname = "WhatsAPI Test"; $sender = "91974***"; // Mobile number with country code (but without + or 00) $imei = "My IMEI number here"; // MAC Address for iOS IMEI for other platform (Android/etc)

$countrycode = substr($sender, 0, 2); $phonenumber=substr($sender, 2); echo "[] Logging in as '$nickname' ($sender)\n"; $wa = new WhatsProt($sender, $imei, $nickname, true);

$url = "https://r.whatsapp.net/v1/exist.php?cc=".$countrycode."&in=".$phonenumber."&udid=".$wa->encryptPassword(); $content = file_get_contents($url); if(stristr($content,'status="ok"') === false){ echo "Wrong Password\n"; exit(0); } $wa->Connect(); $wa->Login();

$dst = "9199****"; $msg = "Whatsup bro"; echo "\n[] Send message to $dst: $msg\n"; $wa->Message(time()."-1", $dst , $msg);

The output i see is....

!/usr/bin/php [] Logging in as 'WhatsAPI Test' (91974**1) tx tx tx tx rx rx rx rx rx û° ¿m.a¦x¦m9T½è`º,tg tx a®÷3g‹È±K¨è Lӝ”™Ã}»Ñõzuð ZŒ´‰­·Ý©â?ÊGÊKa rx MW ùõ“ìnZO’m¿2¾sÙfO$ tx tx [] Send message to 9199****_: Whatsup bro tx tx tx tx tx tx tx 9199_***\ tx

z0rax commented 11 years ago

I believe WhatsApp crew did some changes. Try doing

php whatsapp.php -l

Should be giving you a timeout error (socket_read()) as of the latest version of this script source. My guess is they changed their network configs, such as IPs, and possibly port, which is why we can't grab any data when trying to listen or send messages.

This is what I get when I do

php whatsapp.php -s MyNumberHere "Text Here"

php whatsapp.php -s MyNumberGere "Text Here"

[] Logging in as 'WhatsAPI Test' (TargetNumber)

tx stream:features tx tx /stream:features

tx

rx

rx stream:features rx rx /stream:features

¦!úÅ!Ç«GàƒËýÅ:ietf:params:xml:ns:xmpp-sasl"> ☼L└P¼

tx Áõ#[û+┴O n♠l╝¥A§─¶°ò↨·¢Aû û│↨ â▼░[Q♫,LÖôÂÞ§f

rx Tí³G:╔1ýÃ║ºñíXÂÇQ=

tx

tx

[] Request last seen MyNumberHere: tx tx tx

[] Send message to MyNumberHere: Text Here

tx tx tx tx tx tx tx MyNumberHere tx

And no messages ever get sent to my phone. My guess is the configs are wrong in the current version of this script.

ghost commented 11 years ago

No, i don't think the IP addresses and Port were changed because i'm still able to change my status successfully, the only issue seems to be with the receiving and sending of messages. They must've changed their encryption protocol or something.

z0rax commented 11 years ago

Then what about listening mode ? Unable to read and/or write with the sockets.... But yeah, looks like protocol.

z0rax commented 11 years ago

I started using

$wa->Message( target, "text") instead of $wa->Message( time() . "-1", target, "text") and it works sometimes. Need to refresh the php document a few times sometimes but it does work, for now.

ghost commented 11 years ago

I did not check out the listening mode. I wrote my own code looking at the example. In my code the message function is already modified. So it's fine. Something else seems to be going wrong :(

z0rax commented 11 years ago

A few days ago the $wa->Message( target, "text"); was working properly (Removing the time(). "-1", part). Now, it just displays the message as a notification on your phone, but does not actually send a message to the target. It just displays the notification.

Seems like to me the protocol is just going worse and worse..

brittson commented 11 years ago

password method is changed ,so if your mobile is updated with new version of whatsapp,msgs wont go