From 62601efa77dbea42331ce818de5f0bc5e9a20ae3 Mon Sep 17 00:00:00 2001 From: shirioko Date: Wed, 26 Mar 2014 17:10:16 +0100 Subject: [PATCH] Added sendGetStatuses fixes #33 --- src/php/whatsprot.class.php | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/php/whatsprot.class.php b/src/php/whatsprot.class.php index 28567e34..04f61a51 100644 --- a/src/php/whatsprot.class.php +++ b/src/php/whatsprot.class.php @@ -810,18 +810,27 @@ public function sendGetServerProperties() * Get the current status message of a specific user. * * @deprecated Use ContactSyncV2 to get status - * @param string $jid The user JID + * @param string[] $jids The users' JIDs */ - public function sendGetStatus($jid) + public function sendGetStatuses($jids) { - $parts = explode("@", $jid); - $to = $parts[0] . "@s.us"; - $child = new ProtocolNode("action", array("type" => "get"), null, null); - $node = new ProtocolNode("message", array( - "to" => $to, - "type" => "action", - "id" => $this->createMsgId("message") - ), array($child), null); + if(!is_array($jids)) + { + $jids = array($jids); + } + $children = array(); + foreach($jids as $jid) + { + $children[] = new ProtocolNode("user", array("jid" => $this->getJID($jid)), null, null); + } + $node = new ProtocolNode("iq", array( + "to" => "s.whatsapp.net", + "type" => "get", + "xmlns" => "status", + "id" => $this->createMsgId("getstatus") + ), array( + new ProtocolNode("status", null, $children, null) + ), null); $this->sendNode($node); }