本文整理汇总了PHP中WhatsProt::eventManager方法的典型用法代码示例。如果您正苦于以下问题:PHP WhatsProt::eventManager方法的具体用法?PHP WhatsProt::eventManager怎么用?PHP WhatsProt::eventManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhatsProt
的用法示例。
在下文中一共展示了WhatsProt::eventManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: config
public function config($number, $nickname, $password, $debug = false, $identifyFile = false)
{
$this->setNumber($number);
$this->setNick($nickname);
$this->setPassword($password);
$this->setDebug($debug);
$this->wa = new \WhatsProt($this->number, $this->nick, $this->debug, $identifyFile);
$this->wa->eventManager()->bind('onGetMessage', array($this, 'processReceivedMessage'));
$this->wa->eventManager()->bind('onConnect', array($this, 'connected'));
$this->wa->eventManager()->bind('onGetGroups', array($this, 'processGroupArray'));
$this->wa->eventManager()->bind('onCodeRequestFailedTooRecent', array($this, 'throwTooRecentException'));
$this->wa->eventManager()->bind('onCodeRequestFailedTooManyGuesses', array($this, 'throwTooManyGuessesException'));
$this->wa->eventManager()->bind('onCodeRequestFailed', array($this, 'throwCodeRequestFailedException'));
$this->wa->eventManager()->bind('onCodeRegisterFailed', array($this, 'throwCodeRegisterFailedException'));
}
示例2: time
<?php
require "ZermeloRoosterPHP/Cache.php";
require "ZermeloRoosterPHP/Zermelo.php";
require "Chat-API/src/whatsprot.class.php";
require "Chat-API/src/events/MyEvents.php";
require "Chat-API/src/smileys.class.php";
require "config.php";
date_default_timezone_set("Europe/Amsterdam");
$startTime = time();
$w = new WhatsProt($username, $nickname, $debug);
$s = new Smileys();
$events = new MyEvents($w);
$w->eventManager()->bind("onGetMessage", "onGetMessage");
$w->eventManager()->bind("onGetGroupMessage", "onGetGroupMessage");
$w->eventManager()->bind("onNumberWasAdded", "onNumberWasAdded");
$w->eventManager()->bind("onNumberWasRemoved", "onNumberWasRemoved");
$w->eventManager()->bind("onNumberWasUpdated", "onNumberWasUpdated");
$w->eventManager()->bind("onProfilePictureChanged", "onProfilePictureChanged");
$w->connect();
$w->loginWithPassword($password);
$w->sendGetPrivacyBlockedList();
$w->sendGetClientConfig();
$w->sendGetServerProperties();
$w->sendGetGroups();
$w->sendGetBroadcastLists();
// $w->sendStatusUpdate("Zermelo Bot (c) Bas van den Wollenberg");
// $w->sendSetProfilePicture("http://i.imgur.com/ztpQ4uV.png");
while (true) {
$w->pollMessage();
}
示例3: onPresenceUnavailable
echo "<{$dFrom} is online>\n\n";
}
function onPresenceUnavailable($username, $from, $last)
{
$dFrom = str_replace(array("@s.whatsapp.net", "@g.us"), "", $from);
echo "<{$dFrom} is offline> Last seen: {$last} seconds\n\n";
}
echo "[] Logging in as '{$nickname}' ({$username})\n";
//Create the whatsapp object and setup a connection.
$w = new WhatsProt($username, $nickname, $debug);
$w->connect();
// Now loginWithPassword function sends Nickname and (Available) Presence
$w->loginWithPassword($password);
//Retrieve large profile picture. Output is in /src/php/pictures/ (you need to bind a function
//to the event onProfilePicture so the script knows what to do.
$w->eventManager()->bind("onGetProfilePicture", "onGetProfilePicture");
$w->sendGetProfilePicture($target, true);
//Print when the user goes online/offline (you need to bind a function to the event onPressence
//so the script knows what to do)
$w->eventManager()->bind("onPresenceAvailable", "onPresenceAvailable");
$w->eventManager()->bind("onPresenceUnavailable", "onPresenceUnavailable");
echo "[*] Connected to WhatsApp\n\n";
//update your profile picture
$w->sendSetProfilePicture("demo/venom.jpg");
//send picture
$w->sendMessageImage($target, "demo/x3.jpg");
//send video
//$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
示例4: exit
echo "====================================================\n";
echo " WhatsApp Tracker v0.1 \n";
echo "====================================================\n\n";
echo "USAGE: php " . $_SERVER['argv'][0] . " [-check <targetPhone>] [-cHidden <targetPhone>]\n [-cRemote0 <myPhone> <targetPhone>] [-cRemote1 <myPhone> <targetPhone>]\n";
exit(1);
}
$dst = $_SERVER['argv'][2];
echo "====================================================\n";
echo " WhatsApp tracker v0.1 \n";
echo "====================================================\n\n";
echo "[*] Logging in as WhatsApp Tracker ({$sender})\n";
$wa = new WhatsProt($sender, 'WhatsApp Tracker', FALSE);
$wa->connect();
$wa->loginWithPassword($password);
$events = new MyEvents($wa);
$wa->eventManager()->bind('onGetRequestLastSeen', 'onGetRequestLastSeen');
$wa->eventManager()->bind("onPresenceAvailable", "onPresenceAvailable");
$wa->eventManager()->bind("onPresenceUnavailable", "onPresenceUnavailable");
if ($_SERVER['argv'][1] == "-cRemote0" || $_SERVER['argv'][1] == "-check") {
echo "\n[-] Tracker mode (ON):\n";
while (TRUE) {
if ($_SERVER['argv'][1] == "-check") {
$wa->sendGetRequestLastSeen($dst);
} else {
$wa->sendGetRequestLastSeen($_SERVER['argv'][3]);
$wa->sendMessage($dst, "(" . $_SERVER['argv'][3] . ") " . $ls);
}
sleep(60);
}
}
if ($_SERVER['argv'][1] == "-cHidden" || $_SERVER['argv'][1] == "-cRemote1") {
示例5: WhatsProt
if ($type == "available") {
echo "<{$dFrom} is online>\n\n";
} else {
echo "<{$dFrom} is offline>\n\n";
}
}
echo "[] Logging in as '{$nickname}' ({$username})\n";
//Create the whatsapp object and setup a connection.
$w = new WhatsProt($username, $identity, $nickname, $debug);
$w->connect();
// Now loginWithPassword function sends Nickname and (Available) Presence
$w->loginWithPassword($password);
echo "[*] Connected to WhatsApp\n\n";
//Retrieve large profile picture. Output is in /src/php/pictures/ (you need to bind a function
//to the event onProfilePicture so the script knows what to do.
$w->eventManager()->bind("onGetProfilePicture", "onGetProfilePicture");
$w->sendGetProfilePicture($target, true);
//Print when the user goes online/offline (you need to bind a function to the event onPressence
//so the script knows what to do)
$w->eventManager()->bind("onPresence", "onPresenceReceived");
//update your profile picture
$w->sendSetProfilePicture("demo/venom.jpg");
//send picture
$w->sendMessageImage($target, "demo/x3.jpg");
//send video
//$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
示例6: onGetProfilePicture
$minutes = floor($minuteSeconds / $secondsInAMinute);
// extract the remaining seconds
$remainingSeconds = $minuteSeconds % $secondsInAMinute;
$seconds = ceil($remainingSeconds);
// return the value
if ($seconds == null & $minutes == null & $hours == null & $days == null) {
echo "El contacto tiene desactivado esta función";
} else {
if ($seconds == 0 & $minutes == 0 & $hours == 0 & $days == 0) {
echo "En línea";
} else {
echo $days . " días " . $hours . " horas " . $minutes . " minutos";
}
}
}
$w->eventManager()->bind('onGetRequestLastSeen', 'onGetRequestLastSeen');
$w->sendGetRequestLastSeen($contacts);
//This function only needed to show how eventmanager works.
function onGetProfilePicture($from, $target, $type, $data)
{
if ($type == "preview") {
$filename = "preview_" . $target . ".jpg";
} else {
$filename = $target . ".jpg";
}
$filename = WhatsProt::PICTURES_FOLDER . "/" . $filename;
$fp = @fopen($filename, "w");
if ($fp) {
fwrite($fp, $data);
fclose($fp);
}
示例7: onPresenceUnavailable
echo "<{$dFrom} is online>\n\n";
}
function onPresenceUnavailable($username, $from, $last)
{
$dFrom = str_replace(['@s.whatsapp.net', '@g.us'], '', $from);
echo "<{$dFrom} is offline> Last seen: {$last} seconds\n\n";
}
echo "[] Logging in as '{$nickname}' ({$username})\n";
//Create the whatsapp object and setup a connection.
$w = new WhatsProt($username, $nickname, $debug);
$w->connect();
// Now loginWithPassword function sends Nickname and (Available) Presence
$w->loginWithPassword($password);
//Retrieve large profile picture. Output is in /src/php/pictures/ (you need to bind a function
//to the event onProfilePicture so the script knows what to do.
$w->eventManager()->bind('onGetProfilePicture', 'onGetProfilePicture');
$w->sendGetProfilePicture($target, true);
//Print when the user goes online/offline (you need to bind a function to the event onPressence
//so the script knows what to do)
$w->eventManager()->bind('onPresenceAvailable', 'onPresenceAvailable');
$w->eventManager()->bind('onPresenceUnavailable', 'onPresenceUnavailable');
echo "[*] Connected to WhatsApp\n\n";
//update your profile picture
$w->sendSetProfilePicture('demo/venom.jpg');
//send picture
$w->sendMessageImage($target, 'demo/x3.jpg');
//send video
//$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
示例8: exit
echo " WhatsApp tracker v0.2 \n";
echo "====================================================\n\n";
if ($sender == "") {
echo "\nEdit this file and add your account and password\n";
exit(0);
}
echo "[*] Logging in as WhatsApp Tracker ({$sender})\n";
$wa = new WhatsProt($sender, 'WhatsApp Tracker', FALSE);
$wa->connect();
try {
$wa->loginWithPassword($password);
} catch (Exception $e) {
echo "Bad authentication: Bad password or blocked account";
}
$events = new MyEvents($wa);
$wa->eventManager()->bind("onPresenceAvailable", "onPresenceAvailable");
$wa->eventManager()->bind("onPresenceUnavailable", "onPresenceUnavailable");
echo "\n[-] Tracker mode (ON): Waiting the user to get online...\n";
$wa->SendPresenceSubscription($target);
$wa->pollMessage();
if ($presence == "available") {
echo "- The user is now online\n\n";
} else {
echo "- The user is offline\n\n";
}
$lastpresence = "";
while (true) {
$wa->pollMessage();
if ($lastpresence == "available" && $presence == "unavailable") {
$timeOffline = date("Y-m-d H:i:s");
while ($presence == "unavailable") {
示例9: onPresenceReceived
return trim(fgets($pStdn, 1024));
}
return null;
}
function onPresenceReceived($username, $from, $type)
{
$dFrom = str_replace(array("@s.whatsapp.net", "@g.us"), "", $from);
if ($type == "available") {
echo "<{$dFrom} se ha conectado>\n\n";
} else {
echo "<{$dFrom} se ha desconectado>\n\n";
}
}
echo "[] Iniciando sesion como '{$nickname}' ({$username})\n";
$w = new WhatsProt($username, $identity, $nickname, false);
$w->eventManager()->bind("onPresence", "onPresenceReceived");
$w->connect();
// Nos conectamos a la red de WhatsApp
$w->loginWithPassword($password);
// Iniciamos sesion con nuestra contraseña
echo "[*]Conectado a WhatsApp\n\n";
$w->sendGetServerProperties();
// Obtenemos las propiedades del servidor
$w->sendClientConfig();
// Enviamos nuestra configuración al servidor
$sync = array($target);
$w->sendSync($sync);
// Sincronizamos el contacto
$w->pollMessages();
// Volvemos a poner en cola mensajes
$w->sendPresenceSubscription($target);
示例10: WhatsProt
}
//format message
$msg = "<a href='{$fulluri}' target='_blank'><img src='{$previewuri}' /></a>";
//insert message
session_start();
$in = $_SESSION['inbound'];
$in[] = $msg;
$_SESSION['inbound'] = $in;
session_write_close();
}
require_once '../../src/whatsprot.class.php';
$target = @$_POST['target'];
$username = 'Inside';
$password = 'onIzWFKkzwKJ8dDxDpCfc9Hr3+o=';
$w = new WhatsProt($username, 0, 'WhatsApi AJAX Demo', true);
$w->eventManager()->bind('onGetImage', 'onGetImage');
$w->eventManager()->bind('onGetProfilePicture', 'onGetProfilePicture');
$w->connect();
$w->loginWithPassword($password);
$initial = @$_POST['initial'];
if ($initial == 'true' && $target != null) {
//request contact picture only on first call
$w->sendGetProfilePicture($target);
}
//subscribe contact status
$w->SendPresenceSubscription($target);
//TODO: presense handling (online/offline/typing/last seen)
while (running($time)) {
while ($w->pollMessage()) {
}
running($time);
示例11: onGetGroups
<?php
require_once '../whatsprot.class.php';
$username = "436646473355";
//Mobile Phone prefixed with country code so for india it will be 91xxxxxxxx
$password = "Z10t1ePNG1CsjZy5hrnHgXm/v1g=";
$w = new WhatsProt($username, 0, "ADarkHero Whatsapp Bot", true);
//Name your application by replacing "WhatsApp Messaging"
$w->connect();
$w->loginWithPassword($password);
$w->eventManager()->bind("onGetGroups", "onGetGroups");
$w->sendGetGroups();
function onGetGroups($phone, $groups)
{
echo var_dump($groups);
}
?>
示例12: setupWhatsappHandler
function setupWhatsappHandler()
{
global $wa, $whatsappAuth;
// bind event handler & tracker_login
// Setup new Whatsapp session
// change the "false" to "true" if you want debug information about the WhatsApp connection.
$wa = new WhatsProt($whatsappAuth['number'], "WhatsApp", $whatsappAuth['debug']);
$wa->eventManager()->bind('onGetRequestLastSeen', 'onGetRequestLastSeen');
$wa->eventManager()->bind('onGetError', 'onGetError');
$wa->eventManager()->bind('onDisconnect', 'onDisconnect');
$wa->eventManager()->bind("onPresenceAvailable", "onPresenceAvailable");
$wa->eventManager()->bind("onPresenceUnavailable", "onPresenceUnavailable");
$wa->eventManager()->bind("onGetStatus", "onGetStatus");
$wa->eventManager()->bind('onGetSyncResult', 'onSyncResultNumberCheck');
$wa->eventManager()->bind("onGetProfilePicture", "onGetProfilePicture");
$wa->eventManager()->bind("onPing", "onPing");
$wa->eventManager()->bind("onSendPong", "onSendPong");
$wa->connect();
$wa->loginWithPassword($whatsappAuth['secret']);
}
示例13: WhatsProt
//echo ."/".."/". ;
$wa = new WhatsProt($_POST['mobile'], $_POST['imei'], $_POST['nickname'], false);
$wa->eventManager()->bind("onCodeRequest", "enriver_onCodeRequest");
$wa->connect();
$wa->codeRequest();
for ($i = 0; $i < 5; $i++) {
$wa->pollMessages();
}
$content = "<h2>You will get 6 digit code on your mobile,Enter the 6 digit code here (without dash)";
$content .= "<form method='post' action='" . elgg_get_site_url() . "enriver/setup/whatsapp/{$segments['2']}/3'>";
$content .= "<input type='text' name='code'>";
$content .= "<input type='submit' name='submit'></form>";
} elseif ($step == '3') {
require elgg_get_plugins_path() . 'enriver/vendors/whatsapi/whatsprot.class.php';
$wa = new WhatsProt($group->whatsapp_mobile, $group->whatsapp_imei, $group->whatsapp_name, false);
$wa->eventManager()->bind("onCodeRegister", "enriver_onCodeRegister");
$wa->connect();
$wa->codeRegister($_POST['code']);
for ($i = 0; $i < 5; $i++) {
$wa->pollMessages();
}
$content = "<h2>Send Test message to other phone number,(make sure other phone has " . $group->whatsapp_mobile . " in contact. ";
$content .= "<form method='post' action='" . elgg_get_site_url() . "enriver/setup/whatsapp/{$segments['2']}/4'>";
$content .= "<label>Mobile Number </label> <input type='text' style='width:400px;' name='testmobile'>";
$content .= "<br><input type='submit'class='elgg-button elgg-button-action' name='submit'></form>";
} elseif ($step == '4') {
// echo $group->whatsapp_mobile."".$group->whatsapp_password;
require elgg_get_plugins_path() . 'enriver/vendors/whatsapi/whatsprot.class.php';
$wa = new WhatsProt($group->whatsapp_mobile, $group->whatsapp_imei, $group->whatsapp_name, false);
$wa->connect();
$wa->loginWithPassword($group->whatsapp_password);
示例14: date
pcntl_exec($_, $argv);
};
set_exception_handler($restartMyself);
register_shutdown_function($restartMyself);
pcntl_signal(SIGTERM, $restartMyself);
// kill
pcntl_signal(SIGHUP, $restartMyself);
// kill -s HUP or kill -1
// pcntl_signal(SIGINT, $restartMyself); // Ctrl-C
echo "[{$ke}][" . date('H:i:s') . "] ----------------------------------------------------\n";
echo "[{$ke}][" . date('H:i:s') . "] - Login sebagai '{$nickname}' ({$username})\n";
cek_konek();
$w = new WhatsProt($username, $nickname, $debug);
// bind events ------------------------------------------------------------------------------------------------------
// list semua event --> https://github.com/WHAnonymous/Chat-API/wiki/WhatsAPI-Documentation#list-of-all-events
$w->eventManager()->bind("onConnect", "onConnect");
$w->eventManager()->bind("onDisconnect", "onDisconnect");
$w->eventManager()->bind("onClose", "onClose");
$w->eventManager()->bind("onGetMessage", "onGetMessage");
$w->eventManager()->bind("onGetGroupMessage", "onGetGroupMessage");
// konek ------------------------------------------------------------------------------------------------------------
sleep(3);
$w->connect();
$w->loginWithPassword($password);
$w->sendGetServerProperties();
$w->sendClientConfig();
$w->sendGetGroups();
$w->sendPing();
// poll message loop ------------------------------------------------------------------------------------------------
while (1) {
if ($poll == 5) {
示例15: setupWhatsappHandler
function setupWhatsappHandler()
{
global $wa, $whatsappAuth;
//bind event handler & login
// Setup new Whatsapp session
$wa = new WhatsProt($whatsappAuth['number'], "", "WhatsApp", false);
$wa->eventManager()->bind('onGetRequestLastSeen', 'onGetRequestLastSeen');
$wa->eventManager()->bind('onGetError', 'onGetError');
$wa->eventManager()->bind('onDisconnect', 'onDisconnect');
$wa->eventManager()->bind("onPresence", "onPresenceReceived");
$wa->eventManager()->bind("onGetStatus", "onGetStatus");
$wa->eventManager()->bind('onGetSyncResult', 'onSyncResultNumberCheck');
$wa->eventManager()->bind("onGetProfilePicture", "onGetProfilePicture");
$wa->eventManager()->bind("onSendPong", "onSendPong");
$wa->connect();
$wa->loginWithPassword($whatsappAuth['secret']);
}