Ejemplo n.º 1
0
 case '/add':
     echo "\nEnter the number you want to add > ";
     $numberToAdd = trim(fgets(STDIN));
     do {
         echo "\nIs it right yes/no > ";
         $check = trim(fgets(STDIN));
         if ($check != 'yes') {
             echo "\nEnter the number you want to add > ";
             $numberToAdd = trim(fgets(STDIN));
         }
     } while ($check != 'yes');
     echo "\nEnter the nickname/name > ";
     $nickname = trim(fgets(STDIN));
     $w->sendSync([$numberToAdd], null, 3);
     if ($existUser) {
         $w->sendPresenceSubscription($numberToAdd);
         addContact($numberToAdd, $nickname);
     }
     break;
 case '/delete':
     echo "\nEnter the nickname you want to remove > ";
     $nickname = trim(fgets(STDIN));
     do {
         echo "\nIs it right yes/no > ";
         $check = trim(fgets(STDIN));
         if ($check != 'yes') {
             echo "\nEnter the nickname you want to remove > ";
             $nickname = trim(fgets(STDIN));
         }
     } while ($check != 'yes');
     $numberToRemove = findPhoneByNickname($nickname);
Ejemplo n.º 2
0
$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();
// Volvemos a poner en cola mensajes
$w->sendPresenceSubscription($target);
// Nos suscribimos a la presencia del usuario
$pn = new ProcessNode($w, $target);
$w->setNewMessageBind($pn);
while (1) {
    $w->pollMessage();
    $msgs = $w->getMessages();
    foreach ($msgs as $m) {
        // process inbound messages
        //print($m->NodeString("") . "\n");
    }
    $line = fgets_u(STDIN);
    if ($line != '') {
        if (strrchr($line, ' ')) {
            $command = trim(strstr($line, ' ', true));
        } else {
Ejemplo n.º 3
0
 case '/add':
     echo "\nEnter the number you want to add > ";
     $numberToAdd = trim(fgets(STDIN));
     do {
         echo "\nIs it right yes/no > ";
         $check = trim(fgets(STDIN));
         if ($check != 'yes') {
             echo "\nEnter the number you want to add > ";
             $numberToAdd = trim(fgets(STDIN));
         }
     } while ($check != 'yes');
     echo "\nEnter the nickname/name > ";
     $nickname = trim(fgets(STDIN));
     $w->sendSync([$numberToAdd], null, 3);
     if ($existUser) {
         $w->sendPresenceSubscription($numberToAdd);
         addContact($numberToAdd, $nickname);
     }
     break;
 case '/delete':
     echo "\nEnter the nickname you want to remove > ";
     $nickname = trim(fgets(STDIN));
     do {
         echo "\nIs it right yes/no > ";
         $check = trim(fgets(STDIN));
         if ($check != 'yes') {
             echo "\nEnter the nickname you want to remove > ";
             $nickname = trim(fgets(STDIN));
         }
     } while ($check != 'yes');
     $numberToRemove = findPhoneByNickname($nickname);