/** * @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; }
public function testCreateJID() { $number = '*****@*****.**'; $ret = Identity::createJID($number); $this->assertEquals($number, $ret); $number = '393921234567'; $ret = Identity::createJID($number); $this->assertEquals($number . '@s.whatsapp.net', $ret); // test group $number = '393921234567-1425645'; $ret = Identity::createJID($number); $this->assertEquals($number . '@g.us', $ret); }
/** * @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; }
/** * @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; }
public function uploadMediaFile(MediaFile $mediaFile, Identity $identity, $uploadUrl, $to) { return $this->sendMediaFile($mediaFile, $uploadUrl, Identity::createJID($to), $identity->getPhone()->getPhoneNumber()); }
/** * @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; }