本文整理汇总了PHP中WhatsProt::Message方法的典型用法代码示例。如果您正苦于以下问题:PHP WhatsProt::Message方法的具体用法?PHP WhatsProt::Message怎么用?PHP WhatsProt::Message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhatsProt
的用法示例。
在下文中一共展示了WhatsProt::Message方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
switch ($command) {
case "/query":
$dst = trim(strstr($line, ' ', FALSE));
echo "[] Interactive conversation with {$dst}:\n";
break;
case "/accountinfo":
echo "[] Account Info: ";
$wa->accountInfo();
break;
case "/lastseen":
echo "[] Request last seen {$dst}: ";
$wa->RequestLastSeen("{$dst}");
break;
default:
echo "[] Send message to {$dst}: {$line}\n";
$wa->Message(time() . "-1", $dst, $line);
break;
}
}
}
exit(0);
}
if ($_SERVER['argv'][1] == "-l") {
echo "\n[] Listen mode:\n";
while (TRUE) {
$wa->PollMessages();
$data = $wa->GetMessages();
if (!empty($data)) {
print_r($data);
}
sleep(1);
示例2: getopt
<?php
require "whatsprot.class.php";
# phone number, IMEI, and name, the IMEI is reversed
# and hashed in whatsprot.class.php so just put your
# IMEI here as it is!
$options = getopt("d::", array("debug::"));
$debug = array_key_exists("debug", $options) || array_key_exists("d", $options) ? true : false;
$w = new WhatsProt("***********", "***************", "John Doe", $debug);
$w->Connect();
$w->Login();
$w->Message(time() . "-1", "***********", "yürp");
# To send an image, put the image on the internet somewhere and send it with the MessageImage function.
# if you want to be real fancy then take a scaled down version (100pixel) and base64_encode it,
# and send that as the last parameter to the MessageImage function.
# I wrote a quick function (funcs.php->createIcon) to do all this for you.
# You can also just leave the last param empty to send no icon
# Obviously this needs better integration... but this is a start...
# Also thumb.jpgb64 is just for an example!
$iconfile = "tests/thumb.jpgb64";
$fp = fopen($iconfile, "r");
$icon = fread($fp, filesize($iconfile));
fclose($fp);
$w->MessageImage(time() . "-1", "***********", "https://lh3.googleusercontent.com/-vT0wjhrlTaQ/T_bwd4_PUYI/AAAAAAAABog/oKPZ6ssJqC0/s673/DSC02471.JPG", "DSC02471.jpg", 55508, $icon);
while (1) {
$w->PollMessages();
$msgs = $w->GetMessages();
foreach ($msgs as $m) {
# process inbound messages
#print($m->NodeString("") . "\n");
}
示例3: getopt
<?php
require "whatsprot.class.php";
# phone number, IMEI, and name, the IMEI is reversed
# and hashed in whatsprot.class.php so just put your
# IMEI here as it is!
$options = getopt("d::", array("debug::"));
$debug = array_key_exists("debug", $options) || array_key_exists("d", $options) ? true : false;
# Target phone number
$target = "**********";
$w = new WhatsProt("************", "********", "John Doe", true);
$w->Connect();
# Now Login function sends Nickname and (Available) Presence
$w->Login();
# Implemented out queue messages and auto msgid
$w->Message($target, "1");
$w->Message($target, "2");
$w->Message($target, "3");
$w->Message($target, "4");
$w->Message($target, "5");
# 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");