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
}
$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)) {
            print_r($buff);
        }
        $line = fgets_u(STDIN);
        if ($line != "") {
            if (strrchr($line, " ")) {
                // needs PHP >= 5.3.0
                $command = trim(strstr($line, ' ', TRUE));
            } else {