當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WhatsProt::PollMessages方法代碼示例

本文整理匯總了PHP中WhatsProt::PollMessages方法的典型用法代碼示例。如果您正苦於以下問題:PHP WhatsProt::PollMessages方法的具體用法?PHP WhatsProt::PollMessages怎麽用?PHP WhatsProt::PollMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WhatsProt的用法示例。


在下文中一共展示了WhatsProt::PollMessages方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getopt

# 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");
    }
}
?>

開發者ID:JPG-Consulting,項目名稱:WhatsAPI-1,代碼行數:29,代碼來源:testprotocol.php

示例2: exit

if ($data === null) {
    echo "Error";
    exit(0);
}
list($name, $sender, $pass, $dst, $msg) = explode(":", $data);
$countrycode = substr($sender, 0, 2);
$phonenumber = substr($sender, 2);
echo "[] Logging in as '{$name}' ({$sender})\n";
$wa = new WhatsProt($sender, $pass, $name, true);
$wa->Connect();
$wa->Login();
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));
開發者ID:alec7,項目名稱:Wassapp-PHP,代碼行數:31,代碼來源:send.php


注:本文中的WhatsProt::PollMessages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。