コード例 #1
1
 /**
  * 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());
     }
 }
コード例 #2
0
function sendWhatsapp($target, $message)
{
    $username = "******";
    $password = "******";
    $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);
}
コード例 #3
0
ファイル: WhatsAppApi.php プロジェクト: djade007/WhatsApp
 /**
  * Connect to Whatsapp.
  *
  * Create a connection to the whatsapp servers
  * using the supplied password.
  *
  * @return boolean
  */
 private function connectToWhatsApp()
 {
     if (isset($this->wa)) {
         $this->wa->connect();
         $this->wa->loginWithPassword($this->password);
         return true;
     }
     return false;
 }
コード例 #4
0
ファイル: GetMessage.php プロジェクト: brenodouglas/wpp-cli
 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);
 }
コード例 #5
0
ファイル: SendMessage.php プロジェクト: brenodouglas/wpp-cli
 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!</>');
 }
コード例 #6
0
ファイル: main.php プロジェクト: jorgtledo/whatbot
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);
}
コード例 #7
0
 /** IMPLEMENTS SEND MESSAGES **/
 protected function sendFiles($to, $files)
 {
     set_time_limit(600);
     $explode = explode('.', $files['image']['name']);
     $extensao = end($explode);
     $extensao = strtolower($extensao);
     define('CAMINHO_MIDIA', 'c:/xampp5-6/htdocs/whatsApi/public/img/send-messages/');
     if (in_array($extensao, array('3gp', 'mp4', 'mov', 'avi'))) {
         $newName = md5($files['image']['name'] . date('Ymdhis')) . "." . $extensao;
         $pathImage = CAMINHO_MIDIA . $newName;
         $urlMain = $_SERVER['HTTP_ORIGIN'] . '/img/send-messages/' . $newName;
         if (move_uploaded_file($files['image']['tmp_name'], $pathImage)) {
             $this->managerWhats->sendMessageVideo($to, $urlMain);
             $this->managerWhats->pollMessage();
         } else {
             $this->setLogTalk("Enviar image:" . $to, "Não foi possível enviar a mídia");
         }
     }
     if (in_array($extensao, array('jpg', 'jpeg', 'gif', 'png'))) {
         $newName = md5($files['image']['name'] . date('Ymdhis')) . "." . $extensao;
         $pathImage = CAMINHO_MIDIA . $newName;
         $urlMain = $_SERVER['HTTP_ORIGIN'] . '/img/send-messages/' . $newName;
         if (move_uploaded_file($files['image']['tmp_name'], $pathImage)) {
             $this->managerWhats->sendMessageImage($to, $urlMain);
             $this->managerWhats->pollMessage();
         } else {
             $this->setLogTalk("Enviar image:" . $to, "Não foi possível enviar a mídia");
         }
     }
     if (in_array($extensao, array('3gp', 'caf', 'wav', 'mp3', 'wma', 'ogg', 'aif', 'aac', 'm4a'))) {
         $newName = md5($_FILES['image']['name'] . date('Ymdhis')) . "." . $extensao;
         $pathImage = CAMINHO_MIDIA . $newName;
         $urlMain = $_SERVER['HTTP_ORIGIN'] . '/img/send-messages/' . $newName;
         if (move_uploaded_file($files['image']['tmp_name'], $pathImage)) {
             $this->managerWhats->sendMessageAudio($to, $urlMain);
             $this->managerWhats->pollMessage();
         } else {
             $this->setLogTalk("Enviar image:" . $to, "Não foi possível enviar a mídia");
         }
     }
     return true;
 }
コード例 #8
0
<?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);
}
コード例 #9
0
ファイル: block.php プロジェクト: Cajjunb/ProjetoIdeation
<?php

require_once '../src/whatsprot.class.php';
$nickname = "Leandro";
$username = "******";
// Your number with country code
$identity = "identity";
$password = "******";
// 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();
コード例 #10
0
ファイル: TestWhatsProt.php プロジェクト: jonathan-r/Chat-API
 public function processInboundDataNode(ProtocolNode $node)
 {
     parent::processInboundDataNode($node);
 }
コード例 #11
0
ファイル: whatsapp.php プロジェクト: diamondobama/WhatsAPI
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
コード例 #12
0
ファイル: perfil.php プロジェクト: aristofanio/WhatsApp-Tools
                          
                        </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;
コード例 #13
0
ファイル: pollMessage.php プロジェクト: jeromez80/dutyPhone
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');
コード例 #14
0
ファイル: socket.php プロジェクト: nekulin/WhatsAPI
        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);
コード例 #15
0
ファイル: resetAccount.php プロジェクト: smartm13/whatss
<?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: "******"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";
コード例 #16
0
ファイル: index.php プロジェクト: edmund88/whatsapi-enaijize
<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 = "******";
$password = "******";
$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 = "******";
$dbpassword = "******";
$dbname = "heroku_555506e4f7e7997";
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
while (true) {
コード例 #17
0
ファイル: wasapbot.php プロジェクト: jl91/wasapbot
    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();
コード例 #18
0
ファイル: registerTool.php プロジェクト: nandadotexe/Chat-API
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, do not use + or 00): ";
$username = str_replace("+", "", trim(fgets(STDIN)));
if (!preg_match('!^\\d+$!', $username)) {
    echo "Wrong number. Do NOT use '+' or '00' before your number\n";
    exit(0);
}
$identityExists = file_exists("../src/wadata/id.{$username}.dat");
// Create a instance of WhastPort.
$w = new WhatsProt($username, '', $debug);
if (!$identityExists) {
    echo "\n\nType sms or voice: ";
    $option = fgets(STDIN);
    try {
        $w->codeRequest(trim($option));
    } catch (Exception $e) {
        echo $e->getMessage() . "\n";
        exit(0);
    }
    echo "\n\nEnter the received code: ";
    $code = str_replace("-", "", fgets(STDIN));
    try {
        $result = $w->codeRegister(trim($code));
        echo "\nYour username is: " . $result->login . "\n";
        echo "Your password is: " . $result->pw . "\n";
コード例 #19
0
ファイル: watracker.php プロジェクト: fabiand93/WA-Tracker
    exit(1);
}
$target = $_SERVER['argv'][1];
$notify = "";
if ($argc == 3) {
    $notify = $_SERVER['argv'][2];
}
echo "====================================================\n";
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 {
コード例 #20
0
ファイル: testprotocol.php プロジェクト: neuhaus/WhatsAPI
<?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", "***********", "yurp");
while (1) {
    $w->PollMessages();
    $msgs = $w->GetMessages();
    foreach ($msgs as $m) {
        # process inbound messages
        #print($m->NodeString("") . "\n");
    }
}
?>

コード例 #21
0
ファイル: broadcast.php プロジェクト: sadiqhirani/whatsapinet
require_once 'whatsprot.class.php';
$username = $argv[1];
$password = $argv[2];
$nickname = $argv[3];
$identity = $argv[4];
$method = $argv[5];
$args = $argv[6];
$targets = $argv[7];
echo "Username: "******"\r\n";
echo "Password: "******"\r\n";
echo "Nickname: " . $nickname . "\r\n";
echo "Identity: " . $identity . "\r\n";
echo "Method: " . $method . "\r\n";
echo "Args: " . $args . "\r\n";
$w = new WhatsProt($username, $identity, $nickname, true);
$w->connect();
$w->loginWithPassword($password);
if ($method == "sendStatusUpdate") {
    echo "About to send status update.\r\n";
    $w->sendStatusUpdate($args);
} elseif ($method == "sendProfilePicture") {
    echo "About to send profile picture.\r\n";
    $w->sendSetProfilePicture($args);
} elseif ($method == "broadcastMessage") {
    $targets = explode(",", $targets);
    echo "About to broadcast a message.\r\n" . print_r($targets) . "\r\n";
    $w->sendBroadcastMessage($targets, $args);
} elseif ($method == "sendBroadcastImage") {
    $targets = explode(",", $targets);
    $w->sendBroadcastImage($targets, $args, false);
コード例 #22
0
ファイル: WhatsProt.php プロジェクト: buguelos/eme
 protected function processInboundDataNode(\ProtocolNode $node)
 {
     parent::processInboundDataNode($node);
 }
コード例 #23
0
    file_put_contents($filename, $data);
    echo '- Profile picture saved in ' . Constants::PICTURES_FOLDER . '/' . $filename . "\n";
}
function onPresenceAvailable($username, $from)
{
    $dFrom = str_replace(['@s.whatsapp.net', '@g.us'], '', $from);
    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
コード例 #24
0
ファイル: whatsapp.php プロジェクト: jonathan-r/Chat-API
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, $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) {
        while ($wa->pollMessage()) {
        }
        $buff = $wa->getMessages();
        if (!empty($buff)) {
            print_r($buff);
        }
        $line = fgets_u(STDIN);
        if ($line != '') {
            if (strrchr($line, ' ')) {
コード例 #25
0
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);
    }
}
//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);
//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);
//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');
コード例 #26
0
<?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");
    }
コード例 #27
0
    } elseif ($num_changed_streams > 0) {
        return trim(fgets($pStdn, 1024));
    }
}
function onPresenceAvailable($username, $from)
{
    $dFrom = str_replace(['@s.whatsapp.net', '@g.us'], '', $from);
    echo "<{$dFrom} is online>\n\n";
}
function onPresenceUnavailable($username, $from, $last)
{
    $dFrom = str_replace(['@s.whatsapp.net', '@g.us'], '', $from);
    echo "<{$dFrom} is offline>\n\n";
}
echo "[] logging in as '{$nickname}' ({$username})\n";
$w = new WhatsProt($username, $nickname, $debug);
$w->eventManager()->bind('onPresenceAvailable', 'onPresenceAvailable');
$w->eventManager()->bind('onPresenceUnavailable', 'onPresenceUnavailable');
$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 = [$target];
$w->sendSync($sync);
// Sincronizamos el contacto
$w->pollMessage();
コード例 #28
0
<?php

require_once 'src/whatsprot.class.php';
require 'src/events/MyEvents.php';
$debug = true;
function onCredentialsBad($mynumber, $status, $reason)
{
    if ($reason == 'blocked') {
        echo "\n\nYour number is blocked \n";
    }
    if ($reason == 'incorrect') {
        echo "\n\nWrong identity. \n";
    }
}
function onCredentialsGood($mynumber, $login, $password, $type, $expiration, $kind, $price, $cost, $currency, $price_expiration)
{
    echo "\n\nYour number {$mynumber} with the following password {$password} is not blocked \n";
}
echo "####################\n";
echo "#                  #\n";
echo "# WA Block Checker #\n";
echo "#                  #\n";
echo "####################\n";
echo "\n\nUsername (country code + number without + or 00): ";
$username = trim(fgets(STDIN));
$w = new WhatsProt($username, '', $debug);
$w->eventManager()->bind("onCredentialsBad", "onCredentialsBad");
$w->eventManager()->bind("onCredentialsGood", "onCredentialsGood");
$w->checkCredentials();