/** * @return Node */ public function createNode() { $state = new Node(); $state->setName($this->getState()); $node = new Node(); $node->setName('chatstate')->setAttribute('to', Identity::createJID($this->getTo()))->addChild($state); return $node; }
/** * @return Node */ public function createNode() { $child = new Node(); $child->setName('query'); $node = new Node(); $node->setName('iq'); $node->setAttributes(["id" => 'getgroupinfo-', "type" => "get", "xmlns" => "w:g", "to" => Identity::createJID($this->getGroupId())]); $node->addChild($child); return $node; }
/** * @return Node */ public function createNode() { $listNode = new Node(); $listNode->setName('list'); $listNode->setAttribute('type', $this->getType()); $node = new Node(); $node->setName('iq'); $node->setAttributes(["id" => 'getgroups-', "type" => "get", "xmlns" => "w:g", "to" => "g.us"]); $node->addChild($listNode); return $node; }
/** * @return Node */ public function createNode() { $node = new Node(); $node->setName('iq')->setAttribute('type', 'set')->setAttribute('to', "s.whatsapp.net")->setAttribute('id', null)->setAttribute('xmlns', 'urn:xmpp:whatsapp:dirty'); foreach ($this->getCategories() as $category) { $categoryNode = new Node(); $categoryNode->setName('clean')->setAttribute('type', $category); $node->addChild($categoryNode); } return $node; }
/** * @return Node */ public function createNode() { $server = new Node(); $server->setName('server'); $x = new Node(); $x->setName('x')->setAttribute('xmlns', 'jabber:x:event')->addChild($server); $notify = new Node(); $notify->setName('notify')->setAttribute('xmlns', 'urn:xmpp:whatsapp')->setAttribute('name', $this->getFromName()); $request = new Node(); $request->setName('request')->setAttribute('xmlns', 'urn:xmpp:receipts'); $body = new Node(); $body->setName('body')->setData($this->getBody()); $node = new Node(); $node->setName('message')->setAttribute('id', null)->setAttribute('t', null)->setAttribute('to', Identity::createJID($this->getTo()))->setAttribute('type', 'text')->addChild($x)->addChild($notify)->addChild($request)->addChild($body); return $node; }
/** * Add the auth response * * @param Connection $connection * @param Identity $identity * @param string $challengeData * @return NodeInterface */ protected function createAuthResponseNode(Connection $connection, Identity $identity, $challengeData) { $resp = $this->getAuthData($connection, $identity, $challengeData); $respHash = []; $respHash["xmlns"] = "urn:ietf:params:xml:ns:xmpp-sasl"; $node = Node::fromArray(['name' => 'response', 'attributes' => $respHash, 'data' => $resp]); return $node; }
/** * @param Client $client * @param NodeInterface $node */ protected function sendNotificationAck(Client $client, NodeInterface $node) { $ackNode = new Node(); if ($node->hasAttribute("to")) { $ackNode->setAttribute('from', $node->getAttribute("to")); } if ($node->hasAttribute("participant")) { $ackNode->setAttribute('participant', $node->getAttribute("participant")); } $ackNode->setAttribute('to', $node->getAttribute("from")); $ackNode->setAttribute('class', $node->getName()); $ackNode->setAttribute('id', $node->getAttribute("id")); $ackNode->setAttribute('type', $node->getAttribute("type")); $client->sendNode($ackNode); }
/** * @param NodeInterface $pingNode */ protected function sendPong(NodeInterface $pingNode) { $pongNode = new Node(); $pongNode->setName('iq'); $pongNode->setAttribute('to', Client::WHATSAPP_SERVER); $pongNode->setAttribute('to', $pingNode->getAttribute('id')); $pongNode->setAttribute('type', 'result'); $this->getClient()->sendNode($pongNode); }
/** * @return \Tmv\WhatsApi\Message\Node\NodeInterface|null */ protected function nextTreeInternal() { $token = $this->readInt8(); $size = $this->readListSize($token); $token = $this->readInt8(); if ($token == 1) { $attributes = $this->readAttributes($size); return Node::fromArray(array('name' => 'start', 'attributes' => $attributes)); } elseif ($token == 2) { return null; } $tag = $this->readString($token); $attributes = $this->readAttributes($size); if ($size % 2 == 1) { return Node::fromArray(array('name' => $tag, 'attributes' => $attributes)); } $token = $this->readInt8(); if ($this->isListTag($token)) { $children = $this->readList($token); return Node::fromArray(array('name' => $tag, 'attributes' => $attributes, 'children' => is_array($children) ? $children : array())); } return Node::fromArray(array('name' => $tag, 'attributes' => $attributes, 'data' => $this->readString($token))); }
/** * @param NodeInterface|array $child * @return $this * @throws InvalidArgumentException */ public function addChild($child) { if (is_array($child)) { $child = Node::fromArray($child); } if (!$child instanceof NodeInterface) { throw new InvalidArgumentException("Argument passed is not an instance of NodeInterface"); } $this->children[] = $child; return $this; }
/** * @return Node */ public function createNode() { $node = new Node(); $node->setName('presence'); if ($this->getName()) { $node->setAttribute('name', $this->getName()); } if ($this->getType()) { $node->setAttribute('type', $this->getType()); } if ($this->getLast()) { $node->setAttribute('last', $this->getLast()); } return $node; }
/** * @return Node */ public function createNode() { $syncNode = new Node(); $syncNode->setName('sync'); $syncNode->setAttributes(["mode" => $this->getMode(), "context" => $this->getContext(), "sid" => "" . (time() + 11644477200) * 10000000, "index" => "" . $this->getIndex(), "last" => $this->isLast() ? "true" : "false"]); foreach ($this->getNumbers() as $number) { $userNode = new Node(); $userNode->setName('user')->setData($number); $syncNode->addChild($userNode); } $node = new Node(); $node->setName('iq'); $node->setAttributes(["id" => 'sendsync-', "type" => "get", "xmlns" => "urn:xmpp:whatsapp:sync", "to" => Identity::createJID($this->getTo())]); $node->addChild($syncNode); return $node; }
/** * Add the authentication nodes. * * @return NodeInterface * Return itself. */ protected function createAuthNode() { $authHash = []; $authHash["xmlns"] = "urn:ietf:params:xml:ns:xmpp-sasl"; $authHash["mechanism"] = "WAUTH-2"; $authHash["user"] = $this->getIdentity()->getPhone()->getPhoneNumber(); $data = $this->createAuthBlob(); $node = Node::fromArray(['name' => 'auth', 'attributes' => $authHash, 'data' => $data]); return $node; }
/** * @return Node */ public function createNode() { $b64hash = base64_encode(hash_file("sha256", $this->getMediaFile()->getFilepath(), true)); $mediaNode = new Node(); $mediaNode->setName('media')->setAttribute('hash', $b64hash)->setAttribute('type', $this->getMediaFile()->getType())->setAttribute('size', $this->getMediaFile()->getSize()); $node = new Node(); $node->setName('iq')->setAttribute('id', 'upload-')->setAttribute('to', Client::WHATSAPP_SERVER)->setAttribute('type', 'set')->setAttribute('xmlns', 'w:m')->addChild($mediaNode); return $node; }
/** * @return Node */ public function createNode() { $server = new Node(); $server->setName('server'); $x = new Node(); $x->setName('x')->setAttribute('xmlns', 'jabber:x:event')->addChild($server); $notify = new Node(); $notify->setName('notify')->setAttribute('xmlns', 'urn:xmpp:whatsapp')->setAttribute('name', $this->getFromName()); $request = new Node(); $request->setName('request')->setAttribute('xmlns', 'urn:xmpp:receipts'); $media = new Node(); $media->setName('media')->setAttribute('xmlns', "urn:xmpp:whatsapp:mms")->setAttribute('type', $this->getType())->setAttribute('url', $this->getUrl())->setAttribute('file', $this->getFile())->setAttribute('size', $this->getSize())->setAttribute('hash', $this->getHash())->setData($this->getIconData() ?: ''); $node = new Node(); $node->setName('message')->setAttribute('id', null)->setAttribute('t', null)->setAttribute('to', Identity::createJID($this->getTo()))->setAttribute('type', 'media')->addChild($x)->addChild($notify)->addChild($request)->addChild($media); return $node; }
/** * @return Node */ public function createNode() { $node = new Node(); $node->setName('receipt')->setAttribute('id', $this->getId())->setAttribute('to', $this->getTo()); return $node; }