protected function execute(InputInterface $input, OutputInterface $output)
 {
     $sender = $input->getArgument('sender');
     $imei = $input->getArgument('imei');
     $nickname = $input->getArgument('nickname');
     $receiver = $input->getArgument('receiver');
     $message = $input->getArgument('message');
     $wa = new Protocol($sender, $imei, $nickname);
     $output->write('Connecting...');
     $wa->Connect();
     $output->writeln(' [<info>OK</info>]');
     $output->write('Logging...');
     $wa->Login();
     $output->writeln(' [<info>OK</info>]');
     $output->write('Sending...');
     $wa->Message(time() . '-1', $receiver, $message);
     $output->writeln(' [<info>OK</info>]');
 }
Example #2
0
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 Protocol($sender, $imei, $nickname, true);
$url = "https://r.whatsapp.net/v1/exist.php?cc=" . $countrycode . "&in=" . $phonenumber . "&udid=" . $wa->encryptPassword();
$content = file_get_contents($url);
if (stristr($content, 'status="ok"') === false) {
    echo "Wrong Password\n";
    exit(0);
}
$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)) {