From 9832b1d9847eaa55c98689eacbfec2b8b3b2d898 Mon Sep 17 00:00:00 2001 From: Max Kovaljov Date: Tue, 12 Aug 2014 21:16:16 +0200 Subject: [PATCH] Updated token and fixed slow login Fixes #876 Fixes #778 Fixes #822 --- src/token.php | 2 +- src/whatsprot.class.php | 29 ++++++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/token.php b/src/token.php index 9e944dff..57afb5bf 100644 --- a/src/token.php +++ b/src/token.php @@ -3,7 +3,7 @@ function generateRequestToken($country, $phone) { $signature = "MIIDMjCCAvCgAwIBAgIETCU2pDALBgcqhkjOOAQDBQAwfDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFDASBgNVBAcTC1NhbnRhIENsYXJhMRYwFAYDVQQKEw1XaGF0c0FwcCBJbmMuMRQwEgYDVQQLEwtFbmdpbmVlcmluZzEUMBIGA1UEAxMLQnJpYW4gQWN0b24wHhcNMTAwNjI1MjMwNzE2WhcNNDQwMjE1MjMwNzE2WjB8MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEUMBIGA1UEBxMLU2FudGEgQ2xhcmExFjAUBgNVBAoTDVdoYXRzQXBwIEluYy4xFDASBgNVBAsTC0VuZ2luZWVyaW5nMRQwEgYDVQQDEwtCcmlhbiBBY3RvbjCCAbgwggEsBgcqhkjOOAQBMIIBHwKBgQD9f1OBHXUSKVLfSpwu7OTn9hG3UjzvRADDHj+AtlEmaUVdQCJR+1k9jVj6v8X1ujD2y5tVbNeBO4AdNG/yZmC3a5lQpaSfn+gEexAiwk+7qdf+t8Yb+DtX58aophUPBPuD9tPFHsMCNVQTWhaRMvZ1864rYdcq7/IiAxmd0UgBxwIVAJdgUI8VIwvMspK5gqLrhAvwWBz1AoGBAPfhoIXWmz3ey7yrXDa4V7l5lK+7+jrqgvlXTAs9B4JnUVlXjrrUWU/mcQcQgYC0SRZxI+hMKBYTt88JMozIpuE8FnqLVHyNKOCjrh4rs6Z1kW6jfwv6ITVi8ftiegEkO8yk8b6oUZCJqIPf4VrlnwaSi2ZegHtVJWQBTDv+z0kqA4GFAAKBgQDRGYtLgWh7zyRtQainJfCpiaUbzjJuhMgo4fVWZIvXHaSHBU1t5w//S0lDK2hiqkj8KpMWGywVov9eZxZy37V26dEqr/c2m5qZ0E+ynSu7sqUD7kGx/zeIcGT0H+KAVgkGNQCo5Uc0koLRWYHNtYoIvt5R3X6YZylbPftF/8ayWTALBgcqhkjOOAQDBQADLwAwLAIUAKYCp0d6z4QQdyN74JDfQ2WCyi8CFDUM4CaNB+ceVXdKtOrNTQcc0e+t"; - $classesMd5 = "+XW/7rCZDX9T7YrGQqTmcg=="; + $classesMd5 = "pZ3J/O+F3HXOyx8YixzvPQ=="; $key2 = base64_decode("/UIGKU1FVQa+ATM2A0za7G2KI9S/CwPYjgAbc67v7ep42eO/WeTLx1lb1cHwxpsEgF4+PmYpLd2YpGUdX/A2JQitsHzDwgcdBpUf7psX1BU="); $data = base64_decode($signature) . base64_decode($classesMd5) . $phone; diff --git a/src/whatsprot.class.php b/src/whatsprot.class.php index 89ca3683..f02da44b 100644 --- a/src/whatsprot.class.php +++ b/src/whatsprot.class.php @@ -46,8 +46,8 @@ class WhatsProt const WHATSAPP_SERVER = 's.whatsapp.net'; // The hostname used to login/send messages. const WHATSAPP_UPLOAD_HOST = 'https://mms.whatsapp.net/client/iphone/upload.php'; // The upload host. const WHATSAPP_DEVICE = 'Android'; // The device name. - const WHATSAPP_VER = '2.11.209'; // The WhatsApp version. - const WHATSAPP_USER_AGENT = 'WhatsApp/2.11.209 Android/4.3 Device/GalaxyS3';// User agent used in request/registration code. + const WHATSAPP_VER = '2.11.301'; // The WhatsApp version. + const WHATSAPP_USER_AGENT = 'WhatsApp/2.11.301 Android/4.3 Device/GalaxyS3';// User agent used in request/registration code. /** * Property declarations. @@ -1637,19 +1637,18 @@ protected function doLogin() $this->sendNode($feat); $this->sendNode($auth); - $this->pollMessages(); - $cnt = 0; - do { - $this->pollMessages(); - if($this->challengeData != null) { - $data = $this->createAuthResponseNode(); - $this->sendNode($data); - $this->reader->setKey($this->inputKey); - $this->writer->setKey($this->outputKey); - $this->pollMessages(); - } - } while ($this->challengeData == null && ($cnt++ < 100) && (strcmp($this->loginStatus, static::DISCONNECTED_STATUS) == 0)); - + $this->pollMessage(); + $this->pollMessage(); + $this->pollMessage(); + + if($this->challengeData != null) { + $data = $this->createAuthResponseNode(); + $this->sendNode($data); + $this->reader->setKey($this->inputKey); + $this->writer->setKey($this->outputKey); + $this->pollMessage(); + } + if(strcmp($this->loginStatus, static::DISCONNECTED_STATUS) == 0) { throw new Exception('Login Failure');