venomous0x / WhatsAPI

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

//TODO: This phone prefix split XXX-ZZZZZ... (in token.php) #556

Open lunixxx opened 10 years ago

lunixxx commented 10 years ago

In the file there are lines:

$phone1 = substr($phone, 0, 3);
$phone2 = substr($phone, 3);

Need to change the format for the number 79261234567? Thank you!

lunixxx commented 10 years ago

$req=$w->codeRequest('sms'); result:

Array ( [cc] => 7 [in] => 926*** [to] => 7926*** [lg] => kk [lc] => KZ [method] => sms [mcc] => 401 [mnc] => 001 [token] => Z8lurh3xG8Rv9hDPg6IftYzYqZI%3D [id] => %da9%a3%ee%5ekk%0d2u%bf%ef%95%60%18%90%af%d8%07%09 ) stdClass Object ( [status] => fail [reason] => bad_token ) 

shirioko commented 10 years ago

Which version are you using? The generated token I get for 79261234567 is

YCkfxi0%2FPrlMAybJGivLGrbXZVM%3D

and code request for 79261234566 works just fine.

Can you pull the latest changes from the base repository?

git remote add upstream https://github.com/venomous0x/WhatsAPI.git
git pull upstream master
lunixxx commented 10 years ago

CODE:

$username = "79261248126";
$identity = "fa348e44ec4ba605857b654e1e8672c5";
$nickname = "Jon";
$w = new WhatsProt($username, $identity, $nickname, true);
$req=$w->codeRequest('sms');

RESULT:
Warning: mcrypt_generic_init() [function.mcrypt-generic-init]: Iv size incorrect; supplied length: 24, needed: 16 in Z:\home\alota7.lan\www\test\token.php on line 25
Array ( [cc] => 7 [in] => 9261248126 [to] => 79261248126 [lg] => kk [lc] => KZ [method] => sms [mcc] => 401 [mnc] => 001 [token] => Z8lurh3xG8Rv9hDPg6IftYzYqZI%3D [id] => %f8d%cabc%dbi%f9%e4%16%3b4qu%40%1fc%a6km ) stdClass Object ( [status] => fail [reason] => bad_token ) 
Fatal error: Uncaught exception 'Exception' with message 'There was a problem trying to request the code.' in Z:\home\******.lan\www\test\whatsprot.class.php:317 Stack trace: #0 Z:\home\******.lan\www\test\index.php(26): WhatsProt->codeRequest('sms') #1 {main} thrown in Z:\home\******.lan\www\test\whatsprot.class.php on line 317

source latest "Download ZIP" The first phone number I wrote as an example. Use UTF-8

shirioko commented 10 years ago

You can comment out line 18 to 27 in token.php as it is not used for token generation. See my commit: https://github.com/shirioko/WhatsAPI/commit/6d05d10cd7cd79905c7fcf05cfe2ea6d445a8481

lunixxx commented 10 years ago

ok, commented out, still getting:

Array ( [cc] => 7 [in] => 9261248126 [to] => 79261248126 [lg] => kk [lc] => KZ [method] => sms [mcc] => 401 [mnc] => 001 [token] => Z8lurh3xG8Rv9hDPg6IftYzYqZI%3D [id] => %f8d%cabc%dbi%f9%e4%16%3b4qu%40%1fc%a6km ) stdClass Object ( [status] => fail [reason] => bad_token ) 
Fatal error: Uncaught exception 'Exception' with message 'There was a problem trying to request the code.' in Z:\home\*****.lan\www\test\whatsprot.class.php:317 Stack trace: #0 Z:\home\****.lan\www\test\index.php(26): WhatsProt->codeRequest('sms') #1 {main} thrown in Z:\home\*****.lan\www\test\whatsprot.class.php on line 317
shirioko commented 10 years ago

What's your WHATSAPP_USER_AGENT in whatsprot.class.php and $classesMd5 in token.php?

lunixxx commented 10 years ago

$classesMd5 = "R5bEU+cZUseb0nsx7MNpPA=="; const WHATSAPP_VER = '2.11.149';
const WHATSAPP_USER_AGENT = 'WhatsApp/2.11.149 Android/4.3 Device/GalaxyS3';

%-)

shirioko commented 10 years ago

Can you download my latest version: https://github.com/shirioko/WhatsAPI and try using that?

I've simplified the token generation process so less chance of something going wrong.

lunixxx commented 10 years ago

Thank you very much for your help. Case headway. I am very happy, but can not be sent message..

1) $w->codeRequest('sms'); - OK 2) $str=$w->codeRegister('**_'); - OK result array=

stdClass Object
(
[status] => ok
[login] => 79261248126
[pw] => _****
[type] => existing
[expiration] => 1419151435
[kind] => free
[price] => 33,00 СЂСѓР±.
[cost] => 33.00
[currency] => RUB
[priceexpiration] => 1390730741
)
3) contactsync.php?phone=79261248126&pass=***=&u[]=7902480*_ result: array(3) { ["phonenumber"]=> string(11) "7902480****" ["status"]=> string(13) "Bla-Bla" ["lastupdate"]=> int(1362064659) } 4) Sent message:

$username = "79261248126";
$identity = "e807f1fcf82d132f9bb018ca6738a19f";
$password = "****************************";
$nickname = "John Doe";
$target = "7902480****";
$w = new WhatsProt($username, $identity, $nickname, true);
$w->connect();
$req=$w->loginWithPassword($password);
$req=$w->sendMessage($target, "Sent from WhatsApi at " . time());

result: message-1387888936-1

But the message has not arrived. I feel that is close. The second account, the number is in your address book .. We need your help ...

shirioko commented 10 years ago

can you add $w->pollMessages() after the code above? And can you post the debug output you receive (xml nodes)?

lunixxx commented 10 years ago

Added $w->pollMessages(), no effect... Debug:

debug

shirioko commented 10 years ago

No rx nodes?

lunixxx commented 10 years ago

Yes... NAT? Grey IP?

shirioko commented 10 years ago

Or just your firewall. Make sure you use port 443 for connection in whatsprot.class.php