本文整理汇总了PHP中WhatsProt::pollMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP WhatsProt::pollMessages方法的具体用法?PHP WhatsProt::pollMessages怎么用?PHP WhatsProt::pollMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhatsProt
的用法示例。
在下文中一共展示了WhatsProt::pollMessages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
//$w->sendMessageVideo($target, 'http://techslides.com/demos/sample-videos/small.mp4');
//send Audio
//$w->sendMessageAudio($target, 'http://www.kozco.com/tech/piano2.wav');
//send Location
//$w->sendLocation($target, '4.948568', '52.352957');
// Implemented out queue messages and auto msgid
$w->sendMessage($target, "Sent from WhatsApi at " . time());
/**
* You can create a ProcessNode class (or whatever name you want) that has a process($node) function
* and pass it through setNewMessageBind, that way everytime the class receives a text message it will run
* the process function to it.
*/
$pn = new ProcessNode($w, $target);
$w->setNewMessageBind($pn);
while (1) {
$w->pollMessages();
$msgs = $w->getMessages();
foreach ($msgs as $m) {
# process inbound messages
//print($m->NodeString("") . "\n");
}
}
/**
* Demo class to show how you can process inbound messages
*/
class ProcessNode
{
protected $wp = false;
protected $target = false;
public function __construct($wp, $target)
{
示例2: exit
exit(1);
}
$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));