From 8c269ced1fda1017a34a60da910ba2150de0c334 Mon Sep 17 00:00:00 2001 From: Bashin Date: Sun, 13 Oct 2013 17:56:07 +0200 Subject: [PATCH 1/7] Repaired onProfilePictureChanged event, added onProfilePictureDeleted --- src/php/whatsprot.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/php/whatsprot.class.php b/src/php/whatsprot.class.php index e8d67785..2022df73 100644 --- a/src/php/whatsprot.class.php +++ b/src/php/whatsprot.class.php @@ -1972,6 +1972,23 @@ protected function processInboundData($data) $node->getChild("picture")->getData() )); } + if ($node->hasChild('notification') && $node->getChild('notification')->getAttribute('type') == 'picture') { + if ($node->getChild('notification')->hasChild('set')) { + $this->eventManager()->fire('onProfilePictureChanged', array( + $this->phoneNumber, + $node->getAttribute('from'), + $node->getAttribute('id'), + $node->getAttribute('t') + )); + } else if ($node->getChild('notification')->hasChild('delete')) { + $this->eventManager()->fire('onProfilePictureDeleted', array( + $this->phoneNumber, + $node->getAttribute('from'), + $node->getAttribute('id'), + $node->getAttribute('t') + )); + } + } if ($node->getChild(0) != null && $node->getChild(0)->getTag() == "media") { $this->processUploadResponse($node); } From 65527d388ba9f47c5297174b12c4a81e7dbb337f Mon Sep 17 00:00:00 2001 From: Bashin Date: Sun, 13 Oct 2013 17:59:25 +0200 Subject: [PATCH 2/7] Update whatsprot.class.php --- src/php/whatsprot.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/php/whatsprot.class.php b/src/php/whatsprot.class.php index 2022df73..c919f02a 100644 --- a/src/php/whatsprot.class.php +++ b/src/php/whatsprot.class.php @@ -1981,13 +1981,13 @@ protected function processInboundData($data) $node->getAttribute('t') )); } else if ($node->getChild('notification')->hasChild('delete')) { - $this->eventManager()->fire('onProfilePictureDeleted', array( + $this->eventManager()->fire('onProfilePictureDeleted', array( $this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('t') )); - } + } } if ($node->getChild(0) != null && $node->getChild(0)->getTag() == "media") { $this->processUploadResponse($node); From c7d1d137378df3f4aca6f4a5a091b9820313f671 Mon Sep 17 00:00:00 2001 From: Bashin Date: Sun, 13 Oct 2013 18:01:31 +0200 Subject: [PATCH 3/7] Update whatsprot.class.php --- src/php/whatsprot.class.php | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/php/whatsprot.class.php b/src/php/whatsprot.class.php index c919f02a..1b6dafbe 100644 --- a/src/php/whatsprot.class.php +++ b/src/php/whatsprot.class.php @@ -1752,19 +1752,23 @@ protected function processInboundData($data) $node->getChild(2)->getData() )); } - - - if ($node->getChild('notify') != null && $node->getChild(0)->getAttribute('name') != null && $node->getChild('notification') != null) { - if ($node->getChild(2)->getAttribute('type') == 'picture') { + if ($node->hasChild('notification') && $node->getChild('notification')->getAttribute('type') == 'picture') { + if ($node->getChild('notification')->hasChild('set')) { $this->eventManager()->fire('onProfilePictureChanged', array( $this->phoneNumber, $node->getAttribute('from'), $node->getAttribute('id'), $node->getAttribute('t') )); + } else if ($node->getChild('notification')->hasChild('delete')) { + $this->eventManager()->fire('onProfilePictureDeleted', array( + $this->phoneNumber, + $node->getAttribute('from'), + $node->getAttribute('id'), + $node->getAttribute('t') + )); } } - if ($node->getChild('notify') != null && $node->getChild(0)->getAttribute('name') != null && $node->getChild('media') != null) { if ($node->getChild(2)->getAttribute('type') == 'image') { $this->eventManager()->fire('onGetImage', array( @@ -1972,23 +1976,6 @@ protected function processInboundData($data) $node->getChild("picture")->getData() )); } - if ($node->hasChild('notification') && $node->getChild('notification')->getAttribute('type') == 'picture') { - if ($node->getChild('notification')->hasChild('set')) { - $this->eventManager()->fire('onProfilePictureChanged', array( - $this->phoneNumber, - $node->getAttribute('from'), - $node->getAttribute('id'), - $node->getAttribute('t') - )); - } else if ($node->getChild('notification')->hasChild('delete')) { - $this->eventManager()->fire('onProfilePictureDeleted', array( - $this->phoneNumber, - $node->getAttribute('from'), - $node->getAttribute('id'), - $node->getAttribute('t') - )); - } - } if ($node->getChild(0) != null && $node->getChild(0)->getTag() == "media") { $this->processUploadResponse($node); } From c4d59ef25f18352bdac1b1d40210514c635245ff Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Sat, 2 Nov 2013 22:49:18 +0100 Subject: [PATCH 4/7] Typos fixed as well as incorrectly commented function name --- src/php/exampleRegister.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/php/exampleRegister.php b/src/php/exampleRegister.php index 8fe46c76..4738d348 100644 --- a/src/php/exampleRegister.php +++ b/src/php/exampleRegister.php @@ -48,17 +48,17 @@ $w->codeRequest('sms'); -// You must wait until you receive a code from Whatsapp, either to your phone via a sms +// You must wait until you receive a code from WhatsApp, either to your phone via sms // or phonecall depending on what you selected above. // The function below will only work once you know your code! /** - * Second register account on WhatsApp using the provided code with $w->requestCode();. + * Second register account on WhatsApp using the provided code with $w->codeRequest();. * * @param integer $code - * Numeric code value provided on requestCode(). + * Numeric code value provided on codeRequest(). * * @return object * An object with server response. @@ -66,16 +66,16 @@ * - login: Phone number with country code. * - pw: Account password. * - type: Type of account. - * - expiration: Expiration date in UNIX TimeStamp. + * - expiration: Expiration date in UNIX Timestamp. * - kind: Kind of account. - * - price: Formated price of account. + * - price: Formatted price of account. * - cost: Decimal amount of account. * - currency: Currency price of account. - * - price_expiration: Price expiration in UNIX TimeStamp. + * - price_expiration: Price expiration in UNIX Timestamp. */ $w->codeRegister('123456'); // IT IS VERY IMPORTANT THAT YOU NOTE AND KEEP YOUR DETAILS. // YOU WILL NEED TO UPDATE THE SCRIPT WITH THE PASSWORD ETC. -//Use exampleFunctional.php to continue with the examples. \ No newline at end of file +//Use exampleFunctional.php to continue with the examples. From a920c75e6ab53a3cc301a5f14ecde42669c12b24 Mon Sep 17 00:00:00 2001 From: Daniel Esteban Date: Sat, 9 Nov 2013 10:31:43 +0100 Subject: [PATCH 5/7] added full path on the fopen(countries.csv) line, it doesn't change current behavior and it fix the problem if WhatsAPI is being used from other project/path --- src/php/whatsprot.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/php/whatsprot.class.php b/src/php/whatsprot.class.php index aa6836dc..0e4bb6b1 100644 --- a/src/php/whatsprot.class.php +++ b/src/php/whatsprot.class.php @@ -1419,7 +1419,7 @@ protected function debugPrint($debugMsg) */ protected function dissectPhone() { - if (($handle = fopen('countries.csv', 'rb')) !== false) { + if (($handle = fopen(dirname(__FILE__).'/countries.csv', 'rb')) !== false) { while (($data = fgetcsv($handle, 1000)) !== false) { if (strpos($this->phoneNumber, $data[1]) === 0) { // Return the first appearance. From 641dd7a7873907576e080c2e2df119f3391f5af0 Mon Sep 17 00:00:00 2001 From: KSas Date: Mon, 18 Nov 2013 01:55:34 +0100 Subject: [PATCH 6/7] Update EVENTS.md onGetRequestLastSeen return an array with 4 elements, not with 3! --- EVENTS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/EVENTS.md b/EVENTS.md index e99920b0..fcc3e952 100644 --- a/EVENTS.md +++ b/EVENTS.md @@ -139,6 +139,7 @@ Available events and arguments - thumbnail: The base64_encoded image. - onGetRequestLastSeen: - phone: The user phone number including the country code. + - from: The sender JID. - msgid: The message id. - sec: The number of seconds since the user went offline. - onGetServerProperties: From defb50d6a168d2c71604a462e8393504f31fa033 Mon Sep 17 00:00:00 2001 From: KSas Date: Fri, 29 Nov 2013 08:46:24 +0100 Subject: [PATCH 7/7] Update EVENTS.md added onGetGroupMessage --- EVENTS.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/EVENTS.md b/EVENTS.md index fcc3e952..83acf45d 100644 --- a/EVENTS.md +++ b/EVENTS.md @@ -129,6 +129,15 @@ Available events and arguments - time: The unix time when send message notification. - name: The sender name. - message: The message. +- onGetGroupMessage: + - phone: The user phone number including the country code. + - from: The group JID. + - author: The sender JID. + - msgid: The message id. + - type: The message type. + - time: The unix time when send message notification. + - name: The sender name. + - message: The message. - onGetPrivacyBlockedList: - phone: The user phone number including the country code. - data: Array of data nodes containing numbers you have blocked.