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


PHP WhatsProt類代碼示例

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


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

示例1: sendWhatsapp

function sendWhatsapp($target, $message)
{
    $username = "972532243523";
    $password = "Wf5ZXzlpmLPQmPL0hqA4yxgu6L0=";
    $w = new WhatsProt($username, "דוח סגולה", "A-Report", true);
    $w->connect();
    $w->loginWithPassword($password);
    if (strlen($target) == 8) {
        $target = "9725" . $target;
    } else {
        if (strlen($target) == 10) {
            $target = "972" . substr($target, 1);
        }
    }
    $w->SendPresenceSubscription($target);
    $w->sendMessage($target, $message);
}
開發者ID:moshew,項目名稱:A-Report_SERVER,代碼行數:17,代碼來源:send_whatsapp.php

示例2: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->line('==============================/');
     $this->line('Registering WhatsApp');
     $this->line('==============================/');
     $numbers = Number::where('type', 'like', 'mobile%')->where('features', 'like', '%SMS%')->get(array('number'))->map(function ($number) {
         return $number->number;
     })->toArray();
     if (empty($numbers)) {
         return $this->error('No mobile number found.');
     }
     $number = $this->choice('Choose which number to register.', $numbers);
     $numberObj = Number::where('number', $number)->first();
     if ($numberObj->voice_callback_type != 'tel') {
         $newNumber = $this->ask('Enter your personal mobile number to receive whatsapp verification code.');
         $numberObj->voice_callback_type = 'tel';
         $numberObj->voice_callback_value = $newNumber;
         $isSaved = $numberObj->save();
         if (!$isSaved) {
             return $this->error('Number is fail to update.');
         }
     }
     // confirm personal number to forward call
     $isNumberOkay = $this->confirm('Verification code will be sent to this number, ' . $numberObj->voice_callback_value . '. Proceed?', true);
     if (!$isNumberOkay) {
         return;
     }
     // registering
     $proceed = $this->confirm('This is very important. You will receive the verification code via phone call, you have to key in the code before the phone call end (around 30 secs) and correct on first try, otherwise you have to wait for 30 mins to 24 hours to get another verification code. Proceed?', true);
     $wa = new WhatsProt($number, $number, false);
     try {
         $waResponse = $wa->codeRequest('voice');
         if ($waResponse->status != 'ok') {
             $verificationCode = str_replace('-', '', $this->ask('Enter your verification code.'));
             $waResponse = $wa->codeRegister($verificationCode);
         }
         $numberObj->wa_password = $waResponse->pw;
         //$numberObj->wa_identity = $waResponse->identity;
         $numberObj->wa_expiration = $waResponse->expiration;
         $numberObj->save();
         $this->line('Done. Run following command in supervisord, php artisan whatsapp:start ' . $number);
     } catch (Exception $e) {
         $this->error($e->getMessage());
     }
 }
開發者ID:aa6my,項目名稱:nexmo-dashboard,代碼行數:50,代碼來源:WhatsAppRegister.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $username = getenv('USERNAME');
     $nickname = getenv('NICKNAME');
     $password = getenv('PASSWORD');
     $debug = false;
     // Create a instance of WhastPort.
     $w = new \WhatsProt($username, $nickname, $debug);
     $w->connect();
     // Connect to WhatsApp network
     $w->loginWithPassword($password);
     $events = new CustomEvent($w, $output);
     $events->setEventsToListenFor(['onGetMessage']);
     $w->pollMessage();
     $helper = $this->getHelper('question');
     $question = new Question('..', false);
     $destination = $helper->ask($input, $output, $question);
 }
開發者ID:brenodouglas,項目名稱:wpp-cli,代碼行數:18,代碼來源:GetMessage.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $username = getenv('USERNAME');
     $nickname = getenv('NICKNAME');
     $password = getenv('PASSWORD');
     $debug = false;
     // Create a instance of WhastPort.
     $w = new \WhatsProt($username, $nickname, $debug);
     $w->connect();
     // Connect to WhatsApp network
     $w->loginWithPassword($password);
     $helper = $this->getHelper('question');
     $question = new Question('Digite o numero que deseja enviar sua mensagem: ', false);
     $destination = $helper->ask($input, $output, $question);
     $question = new Question('Digite sua mensagem: ', false);
     $message = $helper->ask($input, $output, $question);
     $w->sendMessage($destination, $message);
     $output->writeln('<fg=green>Send message with success!</>');
 }
開發者ID:brenodouglas,項目名稱:wpp-cli,代碼行數:19,代碼來源:SendMessage.php

示例5: start

function start($s_num, $s_encuestan)
{
    require 'config/config_w.php';
    require 'strings.php';
    require 'frase.php';
    require_once 'encuestaloader.php';
    require_once 'encuesta.php';
    $encuestaloader = new Encuestaloader($s_encuestan);
    $encuesta = $encuestaloader->get_encuesta();
    $s_saludo = new Frase();
    echo "Enviar a--> {$s_num}\n";
    echo "Cantidad de preguntas: " . $encuesta->tam() . "\n\n";
    $wa = new WhatsProt($s_sender, $s_nickname, false);
    $wa->connect();
    $wa->loginWithPassword($s_password);
    echo "Presentando...\n";
    envio($wa, $s_saludo->get_stiempo(0) . $s_msg_hi, $s_num);
    $i_contfail = 0;
    do {
        $respa = getresp($wa, $s_num);
        $resp = $respa[0];
        $resp = trim($resp);
        $nombre = $respa[1];
        if (strcasecmp($resp, "Si") == 0 or strcasecmp($resp, "Sí") == 0) {
            echo "Acepto!!\n";
            envio($wa, $s_msg_start, $s_num);
            encuesta_start($wa, $s_num, $encuesta, $nombre);
        } elseif (strcasecmp($resp, "No") == 0) {
            echo "No Acepto.\nDespidiendo...\n";
            envio($wa, $nombre . ' ' . $s_msg_sory . $s_saludo->get_stiempo(1), $s_num);
            exit(0);
        } else {
            echo "Reenvio...\n";
            envio($wa, $nombre . ' ' . $s_msg_retry, $s_num);
        }
        $i_contfail++;
    } while ($i_contfail < 3);
    envio($wa, $nombre . ' ' . $s_msg_sory . $s_saludo->get_stiempo(1), $s_num);
}
開發者ID:jorgtledo,項目名稱:whatbot,代碼行數:39,代碼來源:main.php

示例6: trim

<?php

require_once '../src/whatsprot.class.php';
$debug = true;
echo "####################\n";
echo "#                  #\n";
echo "# WA Register Tool #\n";
echo "#                  #\n";
echo "####################\n";
echo "\n\nUsername (country code + number without + or 00): ";
$username = trim(fgets(STDIN));
// Create a instance of WhastPort.
$w = new WhatsProt($username, '', $debug);
echo "\n\nType sms or voice: ";
$option = fgets(STDIN);
try {
    $w->codeRequest(trim($option));
} catch (Exception $e) {
    echo $e->getMessage();
    exit(0);
}
echo "\n\nEnter the received code: ";
$code = str_replace("-", "", fgets(STDIN));
try {
    $result = $w->codeRegister(trim($code));
    echo "\nYour password is: " . $result->pw . "\n";
} catch (Exception $e) {
    echo $e->getMessage();
    exit(0);
}
開發者ID:PLSV,項目名稱:Digital-Treasure,代碼行數:30,代碼來源:registerTool.php

示例7: WhatsProt

<?php

require_once '../src/whatsprot.class.php';
$nickname = "Leandro";
$username = "55618661990";
// Your number with country code
$identity = "identity";
$password = "266782";
// your password
$target = "516185359872";
// target number (with country code)
$w = new WhatsProt($username, $identity, $nickname, TRUE);
$w->connect();
$w->loginWithPassword($password);
$w->sendMessage($target, "whatever...");
$w->pollMessage();
$w->disconnect();
開發者ID:Cajjunb,項目名稱:ProjetoIdeation,代碼行數:17,代碼來源:block.php

示例8: WhatsProt

<?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->sendSetProfilePicture("profilePic.jpg");
開發者ID:abazad,項目名稱:Good-Morning-WhatsApp-Bot,代碼行數:11,代碼來源:setProfilePicture.php

示例9: exit

if ($argc < 2) {
    echo "USAGE: " . $_SERVER['argv'][0] . " [-l] [-s <phone> <message>] [-i <phone>] [-set <status>]\n";
    echo "\tphone: full number including country code, without '+' or '00'\n";
    echo "\t-s: send message\n";
    echo "\t-l: listen for new messages\n";
    echo "\t-i: interactive conversation with <phone>\n";
    echo "\t-set: Set Status to <status>\n";
    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
開發者ID:diamondobama,項目名稱:WhatsAPI,代碼行數:31,代碼來源:whatsapp.php

示例10: set_time_limit

                          
                        </ul>

                     
             
<?php 
$username = '';
$password = '';
$debug = false;
$contacts = $_POST["pais"] . $_POST["numero"];
$msg = $_POST["mensaje"];
set_time_limit(10);
require_once '/src/whatsprot.class.php';
$nickname = "WA Tools";
$target = $contacts;
$w = new WhatsProt($username, $identity, $nickname, $debug);
$w->connect();
$w->loginWithPassword($password);
if ($msg != "") {
    echo "<b>El mensaje:</b> " . $msg . "  <b>Ha sido enviado con éxito.</b><br><br>";
    $w->sendMessage($contacts, $msg);
    $w->sendMessage($contacts, "Mensaje enviado desde http://watools.es");
}
function onGetRequestLastSeen($username, $msgid, $seconds)
{
    //echo "Received last seen seconds: '$seconds'";
    //$now = time();
    //$lastSeen = $now - $seconds;
    $secondsInAMinute = 60;
    $secondsInAnHour = 60 * $secondsInAMinute;
    $secondsInADay = 24 * $secondsInAnHour;
開發者ID:aristofanio,項目名稱:WhatsApp-Tools,代碼行數:30,代碼來源:perfil.php

示例11: getDutyNumber

function getDutyNumber()
{
    //Get duty number from MySQL
    $select = "SELECT * FROM `mmg_phone_numbers` WHERE id=1";
    $row = mysql_fetch_array(mysql_query($select));
    $dutynumber = $row['current_duty_number'];
    return $dutynumber;
}
function getGroupChats()
{
    //Get duty number from MySQL
    $select = "SELECT group_code FROM `WAGroupChats` WHERE status='enable'";
    return mysql_query($select);
}
echo "Current duty number is" . getDutyNumber() . "\n\n";
$w = new WhatsProt($username, $nickname, $debug);
$GLOBALS["wa"] = $w;
//$w->setMessageStore(new SqliteMessageStore($username));
$events = new MyEvents($w);
$w->eventManager()->bind('onGetMessage', 'onGetMessage');
$w->eventManager()->bind('onGetGroupV2Info', 'onGetGroupV2Info');
$w->eventManager()->bind('onGetGroups', 'onGetGroups');
$w->eventManager()->bind('onGroupisCreated', 'onGroupisCreated');
$w->eventManager()->bind("onGetGroupMessage", "onGetGroupMessage");
$w->eventManager()->bind('onGetSyncResult', 'onSyncResult');
$w->eventManager()->bind('onGetRequestLastSeen', 'onGetRequestLastSeen');
$w->eventManager()->bind('onPresenceAvailable', 'onPresenceAvailable');
$w->eventManager()->bind('onPresenceUnavailable', 'onPresenceUnavailable');
$w->eventManager()->bind('onGetImage', 'onGetImage');
$w->eventManager()->bind('onGetVideo', 'onGetVideo');
$w->eventManager()->bind('onGetAudio', 'onGetAudio');
開發者ID:jeromez80,項目名稱:dutyPhone,代碼行數:31,代碼來源:pollMessage.php

示例12: fclose

        fclose($fp);
    }
    //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 '../whatsprot.class.php';
$target = @$_POST["target"];
$username = "************";
$password = "******************************";
$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)) {
    $w->pollMessages();
    running($time);
開發者ID:nekulin,項目名稱:WhatsAPI,代碼行數:31,代碼來源:socket.php

示例13: trim

<?php

require_once 'src_register/whatsprot.class.php';
$debug = false;
echo "####################\n";
echo "#                  #\n";
echo "#     WA RESET     #\n";
echo "#                  #\n";
echo "####################\n";
echo "\n\nUsername (country code + number without + or 00): ";
$username = trim(fgets(STDIN));
// Create a instance of WhastPort.
$w = new WhatsProt($username, '', $debug);
echo "\n\nYour accounts password: ";
$pw = trim(fgets(STDIN));
$w->connect();
try {
    $w->loginWithPassword($pw);
} catch (Exception $e) {
    echo "Failed to login, make sure your account is not blocked (use blockChecker.php) or check if your password is right\n\n";
    exit(0);
}
$w->sendRemoveAccount();
$i = 0;
for ($i; $i < 5; $i++) {
    $w->pollMessage();
}
$w->disconnect();
unlink("../src/wadata/id.{$username}.dat");
unlink("../src/wadata/nextChallenge.{$username}.dat");
echo "\n\n OK! Now use registerTool.php \n\n";
開發者ID:smartm13,項目名稱:whatss,代碼行數:31,代碼來源:resetAccount.php

示例14: WhatsProt

<html>
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css" />
</head>
<body>
<div class="panel panel-default">
  <div class="panel-heading">Console</div>
  <div class="panel-body jumbotron">
<?php 
require_once 'src/whatsprot.class.php';
require 'src/events/Events.php';
$username = "15169608138";
$password = "5yLAHeyfVd50eFOt17CpT9kpQ/Y=";
$w = new WhatsProt($username, 0, "Enaijize System", true);
$events = new MyEvents($w);
$events->setEventsToListenFor($events->activeEvents);
echo "<b>Connecting...</b>";
$w->connect();
echo "<b>Logging in...</b><br/>";
$w->loginWithPassword($password);
echo "<b>Connecting to database...</b>";
$dbservername = "us-cdbr-iron-east-01.cleardb.net";
$dbusername = "bcdca4bcfe9366";
$dbpassword = "bfc05937";
$dbname = "heroku_555506e4f7e7997";
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
while (true) {
開發者ID:edmund88,項目名稱:whatsapi-enaijize,代碼行數:31,代碼來源:index.php

示例15: date

    global $_, $argv, $ke;
    echo "\n[{$ke}][" . date('H:i:s') . "] - Ada yang salah.. Me-restart bot..\n";
    sleep(10);
    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();
開發者ID:jl91,項目名稱:wasapbot,代碼行數:31,代碼來源:wasapbot.php


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