diff --git a/.gitattributes b/.gitattributes index a664be3a..e69de29b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,49 +0,0 @@ -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain - -*.jpg binary -*.png binary -*.gif binary - -*.cs text=auto diff=csharp -*.vb text=auto -*.c text=auto -*.cpp text=auto -*.cxx text=auto -*.h text=auto -*.hxx text=auto -*.py text=auto -*.rb text=auto -*.java text=auto -*.html text=auto -*.htm text=auto -*.css text=auto -*.scss text=auto -*.sass text=auto -*.less text=auto -*.js text=auto -*.lisp text=auto -*.clj text=auto -*.sql text=auto -*.php text=auto -*.lua text=auto -*.m text=auto -*.asm text=auto -*.erl text=auto -*.fs text=auto -*.fsx text=auto -*.hs text=auto - -*.csproj text=auto merge=union -*.vbproj text=auto merge=union -*.fsproj text=auto merge=union -*.dbproj text=auto merge=union -*.sln text=auto eol=crlf merge=union diff --git a/.gitignore b/.gitignore index 1252d00d..353d1e1d 100644 --- a/.gitignore +++ b/.gitignore @@ -30,94 +30,6 @@ local.properties # PDT-specific .buildpath - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results -**/[Dd]ebug/ -**/[Rr]elease/ -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.vspscc -.builds -**/*.dotCover - -## TODO: If you have NuGet Package Restore enabled, uncomment this -#**/packages/ - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf - -# Visual Studio profiler -*.psess -*.vsp - -# ReSharper is a .NET coding add-in -_ReSharper* - -# Installshield output folder -[Ee]xpress - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish - -# Others -[Bb]in -[Oo]bj -sql -TestResults -*.Cache -ClientBin -stylecop.* -~$* -*.dbmdl -Generated_Code #added for RIA/Silverlight projects - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML - - - ############ ## Windows ############ diff --git a/EVENTS.md b/EVENTS.md index 23df05b1..5c02ecc0 100644 --- a/EVENTS.md +++ b/EVENTS.md @@ -2,7 +2,6 @@ Available events and arguments ============================== See events/WhatsAppEventListener.php. - How to bind a callback to an event ================================== diff --git a/README.md b/README.md index 1e9b8c8c..1a39a602 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,6 @@ Interface to WhatsApp Messenger **It's not about the money, it's about sending a message.** -*I hope that this was a bit more civil than the former "FUCK SPAMMER IF YOU ARE ONE GO FUCK YOURSELF" :)* - *\- [shirioko](https://github.com/shirioko)* ---------- diff --git a/src/php/token.php b/src/php/token.php index fe70922b..834e0d5f 100644 --- a/src/php/token.php +++ b/src/php/token.php @@ -6,7 +6,7 @@ function generateRequestToken($country, $phone) { $noMediaHash = "AAGpM5zvDnFyrsmemfAETcw/kPWMRcCoW96rBU2pphtEOCWNVhSp8QX6"; $waPrefix = "Y29tLndoYXRzYXBw"; $signature = "MIIDMjCCAvCgAwIBAgIETCU2pDALBgcqhkjOOAQDBQAwfDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFDASBgNVBAcTC1NhbnRhIENsYXJhMRYwFAYDVQQKEw1XaGF0c0FwcCBJbmMuMRQwEgYDVQQLEwtFbmdpbmVlcmluZzEUMBIGA1UEAxMLQnJpYW4gQWN0b24wHhcNMTAwNjI1MjMwNzE2WhcNNDQwMjE1MjMwNzE2W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drinking"; diff --git a/src/php/whatsprot.class.php b/src/php/whatsprot.class.php index e4613c3a..cf280a09 100644 --- a/src/php/whatsprot.class.php +++ b/src/php/whatsprot.class.php @@ -26,8 +26,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.139'; // The WhatsApp version. - const WHATSAPP_USER_AGENT = 'WhatsApp/2.11.139 Android/4.3 Device/GalaxyS3';// User agent used in request/registration code. + const WHATSAPP_VER = '2.11.149'; // The WhatsApp version. + const WHATSAPP_USER_AGENT = 'WhatsApp/2.11.149 Android/4.3 Device/GalaxyS3';// User agent used in request/registration code. /** * Property declarations. @@ -580,7 +580,7 @@ public function sendBroadcastVideo($targets, $path, $storeURLmedia = false) * * @param array $categories */ - public function sendClearDirty($categories) + protected function sendClearDirty($categories) { $msgId = $this->createMsgId("cleardirty"); @@ -779,6 +779,7 @@ public function sendGetServerProperties() /** * Get the current status message of a specific user. * + * @deprecated Use ContactSyncV2 to get status * @param string $jid The user JID */ public function sendGetStatus($jid) @@ -922,12 +923,15 @@ public function sendGroupsParticipantsRemove($groupId, $participants) * The recipient. * @param string $txt * The text message. + * @param $id + * + * @return string */ - public function sendMessage($to, $txt) + public function sendMessage($to, $txt, $id = null) { $txt = $this->parseMessageForEmojis($txt); $bodyNode = new ProtocolNode("body", null, null, $txt); - $this->sendMessageNode($to, $bodyNode); + return $this->sendMessageNode($to, $bodyNode, $id); } /** @@ -2492,7 +2496,7 @@ protected function sendGroupsChangeParticipants($groupId, $participants, $tag) * @param $node * The node that contains the message. */ - protected function sendMessageNode($to, $node) + protected function sendMessageNode($to, $node, $id = null) { $serverNode = new ProtocolNode("server", null, null, ""); $xHash = array(); @@ -2509,7 +2513,7 @@ protected function sendMessageNode($to, $node) $messageHash = array(); $messageHash["to"] = $this->getJID($to); $messageHash["type"] = "chat"; - $messageHash["id"] = $this->createMsgId("message"); + $messageHash["id"] = ($id == null?$this->createMsgId("message"):$id); $messageHash["t"] = time(); $messageNode = new ProtocolNode("message", $messageHash, array($xNode, $notnode, $reqnode, $node), ""); @@ -2527,6 +2531,7 @@ protected function sendMessageNode($to, $node) $messageHash["id"], $node ); + return $messageHash["id"]; } /** diff --git a/tests/WhatAppEventTest.php b/tests/WhatAppEventTest.php index e41a3f96..8885ae0c 100644 --- a/tests/WhatAppEventTest.php +++ b/tests/WhatAppEventTest.php @@ -65,6 +65,15 @@ // Assert expected result: $expected = array( //First event raised: + array( + 'onSendMessageReceived', + array( + 0 => '$username', + // 1 = This is the current time. + 2 => '441234123456' + ) + ), + //Second event raised: array( // Event name: 'onGetMessage', @@ -80,9 +89,13 @@ ) ) ); +$old_expected = array($expected[1]); + +unset($actual[0][1][1]); // Remove the time. + // Analyze the results: if( $expected === $actual - && $expected === $old_function_called ) { + && $old_expected === $old_function_called ) { print( "Test Passed.\n"); } else { print( "Test Failed!!!!!\n" ); @@ -102,8 +115,8 @@ ) ); // Analyze the results: $actual = $listener->getAndResetCapture(); -if( $expected === $actual - && $expected === $old_function_called ) { +if( $old_expected === $actual + && $old_expected === $old_function_called ) { print( "Test Passed.\n"); } else { print( "Test Failed!!!!!\n" ); @@ -138,6 +151,15 @@ // Assert expected result: $expected = array( //First event raised: + array( + 'onSendMessageReceived', + array( + 0 => '$username', + // 1 = This is the current time. + 2 => '441234123456-1234567890@g.us' + ) + ), + // Second event raised: array( // Event name: 'onGetGroupMessage', @@ -154,6 +176,7 @@ ) ) ); +unset($actual[0][1][1]); // Remove the time. if( $expected === $actual ) { print( "Test Passed.\n"); diff --git a/tests/whatsapp.php b/tests/whatsapp.php index 657e385b..ad564459 100644 --- a/tests/whatsapp.php +++ b/tests/whatsapp.php @@ -104,5 +104,3 @@ function fgets_u($pStdn) echo "\n[] Send message to $dst: $msg\n"; $wa->sendMessage($dst , $msg); echo "\n"; - -?>