本文整理汇总了PHP中WhatsProt::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP WhatsProt::getMessages方法的具体用法?PHP WhatsProt::getMessages怎么用?PHP WhatsProt::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhatsProt
的用法示例。
在下文中一共展示了WhatsProt::getMessages方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMessages
/** GET MESSAGES AND STORAGE**/
public function getMessages()
{
$result = array();
while ($this->managerWhats->pollMessage()) {
$data = $this->managerWhats->getMessages();
foreach ($data as $message) {
$userSendMessage = $message->getAttribute('from');
list($number, $whatsAppUrl) = explode('@', $userSendMessage);
$result[$userSendMessage]['userSend'] = $message->getAttribute('notify');
if ($message->getChild('media')) {
$mess = $message->getChild("media");
//$mess = $message->getChild("enc");
$result[$userSendMessage]['messages'][] = $mess->getAttribute('url');
$this->storageMessage($this->users->getNmWhatsapp(), $number, $mess->getAttribute('url'), false, true, $message->getAttribute('notify'));
if (!empty($mess->getAttribute('caption'))) {
$this->storageMessage($this->users->getNmWhatsapp(), $number, $mess->getAttribute('caption'), false, false, $message->getAttribute('notify'));
}
} else {
$mess = $message->getChild("body");
//$mess = $message->getChild("enc");
$result[$userSendMessage]['messages'][] = $mess->getData();
$this->storageMessage($this->users->getNmWhatsapp(), $number, $mess->getData(), false, false, $message->getAttribute('notify'));
}
}
}
return $result;
}
示例2: ProcessNode
$w->sendGetServerProperties();
// Obtenemos las propiedades del servidor
$w->sendClientConfig();
// Enviamos nuestra configuración al servidor
$sync = [$target];
$w->sendSync($sync);
// Sincronizamos el contacto
$w->pollMessage();
// Volvemos a poner en cola mensajes
$w->sendPresenceSubscription($target);
// Nos suscribimos a la presencia del usuario
$pn = new ProcessNode($w, $target);
$w->setNewMessageBind($pn);
while (1) {
$w->pollMessage();
$msgs = $w->getMessages();
foreach ($msgs as $m) {
// process inbound messages
//print($m->NodeString("") . "\n");
}
$line = fgets_u(STDIN);
if ($line != '') {
if (strrchr($line, ' ')) {
$command = trim(strstr($line, ' ', true));
} else {
$command = $line;
}
switch ($command) {
case '/query':
$dst = trim(strstr($line, ' ', false));
echo "[] Interactive conversation with {$contact}:\n";
示例3: WhatsProt
}
$dst = $_SERVER['argv'][2];
$msg = "";
for ($i = 3; $i < $argc; $i++) {
$msg .= $_SERVER['argv'][$i] . " ";
}
echo "[] Logging in as '{$nickname}' ({$sender})\n";
$wa = new WhatsProt($sender, $imei, $nickname, TRUE);
$wa->connect();
$wa->loginWithPassword($password);
if ($_SERVER['argv'][1] == "-i") {
echo "\n[] Interactive conversation with {$dst}:\n";
stream_set_timeout(STDIN, 1);
while (TRUE) {
$wa->pollMessages();
$buff = $wa->getMessages();
if (!empty($buff)) {
print_r($buff);
}
$line = fgets_u(STDIN);
if ($line != "") {
if (strrchr($line, " ")) {
// needs PHP >= 5.3.0
$command = trim(strstr($line, ' ', TRUE));
} else {
$command = $line;
}
switch ($command) {
case "/query":
$dst = trim(strstr($line, ' ', FALSE));
echo "[] Interactive conversation with {$dst}:\n";
示例4: running
running($time);
//check again if timestamp has been updated
//check for outbound messages to send:
session_start();
$outbound = $_SESSION["outbound"];
$_SESSION["outbound"] = array();
session_write_close();
if (count($outbound) > 0) {
foreach ($outbound as $message) {
//send messages
$w->sendMessage($message["target"], $message["body"]);
$w->pollMessages();
}
}
//check for received messages:
$messages = $w->getMessages();
if (count($messages) > 0) {
session_start();
$inbound = $_SESSION["inbound"];
$_SESSION["inbound"] = array();
//lock
foreach ($messages as $message) {
$data = @$message->getChild("body")->getData();
if ($data != null && $data != '') {
$inbound[] = $data;
}
}
$_SESSION["inbound"] = $inbound;
session_write_close();
}
}