コード例 #1
0
 public function sendMessage($to, $message, $files = null)
 {
     if (!empty($files)) {
         $return['midias'] = $this->sendFiles($to, $files);
     }
     if (!empty($message)) {
         $return['message'] = $this->managerWhats->sendMessage($to, $message);
         $this->storageMessage($to, $this->users->getNmWhatsapp(), $message);
         if (empty($return['message']) || !isset($return)) {
             $this->setLogTalk('Enviar Mensagem:' . $to . "Não foi possível enviar a mensagem para o cliente");
         }
     }
     return $return;
 }
コード例 #2
0
ファイル: WhatsAppApi.php プロジェクト: djade007/WhatsApp
 /**
  * Sends a message to a contact.
  *
  * Depending on the inputs sends a
  * message/video/image/location message to
  * a contact.
  *
  * @param $toNumbers
  * @param $message
  * @param $type
  * @return array
  */
 public function sendMessage($toNumbers, $message, $type)
 {
     $this->connectToWhatsApp();
     if (!is_array($toNumbers)) {
         $toNumbers = array($toNumbers);
     }
     $messagesId = array();
     foreach ($toNumbers as $to) {
         $id = null;
         if ($type === self::MESSAGE_TYPE_TEXT) {
             $this->wa->sendMessageComposing($to);
             $id = $this->wa->sendMessage($to, $message);
         }
         if ($type === self::MESSAGE_TYPE_IMAGE) {
             $id = $this->wa->sendMessageImage($to, $message);
         }
         if ($type === self::MESSAGE_TYPE_AUDIO) {
             $id = $this->wa->sendMessageAudio($to, $message);
         }
         if ($type === self::MESSAGE_TYPE_VIDEO) {
             $id = $this->wa->sendMessageVideo($to, $message);
         }
         if ($type === self::MESSAGE_TYPE_LOCATION) {
             $id = $this->wa->sendMessageLocation($to, $message['userlong'], $message['userlat'], $message['locationname'], null);
         }
         $messagesId[$to] = $id;
     }
     return $messagesId;
 }
コード例 #3
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);
}
コード例 #4
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!</>');
 }
コード例 #5
0
ファイル: my_test.php プロジェクト: Zetetikos/WhatsBulk
<?php

require '../src/whatsprot.class.php';
$username = "******";
//Mobile Phone prefixed with country code so for india it will be 91xxxxxxxx
$password = "******";
$w = new WhatsProt($username, 0, "WhatsApp Messenger", true);
//Name your application by replacing "WhatsApp Messaging"
$w->connect();
$w->loginWithPassword($password);
$target = '2347018346761';
//Target Phone,reciever phone
$message = 'GOD PUNISH YOU, STUPID. I\'d BURN YOU DOWN, COMPLETELY BURN DOWN EVERY SINGLE ATOM IN YOU AND DIGEST YOUR GODDAMN ASHES, NONESENSE!!!!!!';
$w->SendPresenceSubscription($target);
//Let us first send presence to user
$w->sendMessage($target, $message);
// Send Message
コード例 #6
0
ファイル: index.php プロジェクト: edmund88/whatsapi-enaijize
    while ($message = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        switch ($message["message"]) {
            case "YES":
                if ($message["prev_message"] == "YES" || !$message["prev_message"]) {
                    $reply = "Nothing to confirm. Please enter a valid command.";
                } else {
                    $reply = "Previous message '" . $message["prev_message"] . "' has been confirmed.";
                }
                break;
            default:
                $reply = "You entered '" . $message["message"] . "'. Please reply with 'YES' to confirm.";
        }
        $sql = "UPDATE messages SET new=0 WHERE sender='" . $message["sender"] . "'";
        if ($conn->query($sql) === TRUE) {
            echo "Record updated successfully";
        } else {
            echo "Error: " . $sql . "<br>" . $conn->error;
        }
        echo "<b>Sending...</b><br/>";
        $w->sendMessage($message["sender"], $reply);
    }
}
echo "<b>Disconnecting...</b>";
$w->disconnect();
echo "<b>Done.</b>";
?>
  </div>
</div>
</body>
</html>
コード例 #7
0
ファイル: wasap-sendmsg.php プロジェクト: jl91/wasapbot
// password
// konek ------------------------------------------------------------------------------------------------------------
echo "+ Login sebagai {$nickname} ({$username})\n+\n";
$w = new WhatsProt($username, $nickname, $debug);
sleep(3);
$w->connect();
$w->loginWithPassword($password);
$w->sendGetServerProperties();
$w->sendClientConfig();
$w->sendGetGroups();
$w->sendPing();
// kirim pesan ke nomor tujuan --------------------------------------------------------------------------------------
$target = "62xxxxxxxxxxx";
$pesan = "Halo Dunia!";
echo "+ Mengirim pesan\n";
echo "+  target : {$target}\n";
echo "+  pesan  : {$pesan}\n+\n";
$w->sendMessageComposing($target);
// typing..
sleep(3);
$w->sendMessagePaused($target);
// selesai typing
sleep(1);
$w->sendMessage($target, $pesan);
// kirim pesan
$w->pollMessage();
sleep(1);
$w->pollMessage();
sleep(1);
$w->pollMessage();
echo "+ Selesai\n+\n";
コード例 #8
0
//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
$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');
//send Location
//$w->sendMessageLocation($target, '4.948568', '52.352957');
// Implemented out queue messages and auto msgid
$w->sendMessage($target, "Guess the number :)");
$w->sendMessage($target, "Sent from WhatsApi at " . date('H:i'));
while ($w->pollMessage()) {
}
/**
 * You can create a ProcessNode class (or whatever name you want) that has a process($node) function
 * and pass it through setNewMessageBind, that way everytime the class receives a text message it will run
 * the process function to it.
 */
$pn = new ProcessNode($w, $target);
$w->setNewMessageBind($pn);
echo "\n\nYou can also write and send messages to {$target} (interactive conversation)\n\n> ";
while (1) {
    $w->pollMessage();
    $msgs = $w->getMessages();
    foreach ($msgs as $m) {
コード例 #9
0
ファイル: socket.php プロジェクト: nekulin/WhatsAPI
//subscribe contact status
$w->SendPresenceSubscription($target);
//TODO: presense handling (online/offline/typing/last seen)
while (running($time)) {
    $w->pollMessages();
    running($time);
    //check again if timestamp has been updated
    //check for outbound messages to send:
    session_start();
    $outbound = $_SESSION["outbound"];
    $_SESSION["outbound"] = array();
    session_write_close();
    if (count($outbound) > 0) {
        foreach ($outbound as $message) {
            //send messages
            $w->sendMessage($message["target"], $message["body"]);
            $w->pollMessages();
        }
    }
    //check for received messages:
    $messages = $w->getMessages();
    if (count($messages) > 0) {
        session_start();
        $inbound = $_SESSION["inbound"];
        $_SESSION["inbound"] = array();
        //lock
        foreach ($messages as $message) {
            $data = @$message->getChild("body")->getData();
            if ($data != null && $data != '') {
                $inbound[] = $data;
            }
コード例 #10
0
ファイル: sendwasa.php プロジェクト: eescallon/upload
$wa = new WhatsProt($sender, $nickname, TRUE);
$wa->connect();
$wa->loginWithPassword($password);
echo "\n[] Setting status:\n";
$wa->sendStatusUpdate($status);
$tpl = "Estimado cliente, \n ARAUJO Y SEGOVIA SA, le recuerda el pago de su obligación, la cual a la fecha presenta mora por valor de \$ %saldo%. \n\nLa mora en el pago de sus obligaciones acarrea reportes negativos en centrales de riesgos, así como el cobro de cargos adicionales.\nSi ya ha efectuado su pago, envíenos el comprobante al correo cartera@araujoysegovia.com , cualquier información adicional en el teléfono 0356501190.\n\nPara realizar su pago en linea : http://www.araujoysegovia.com/pagos\n\nNo responda este mensaje, fue generado automáticamente.";
### obtener
//$list = array(array('tel_celular'=>'3175102281','saldo_a'=>2050030),
//   array('tel_celular'=>'3013248324','saldo_a'=>2050030),
//  array('tel_celular'=>'3164539256','saldo_a'=>2050030),
//     );
foreach ($list as $row) {
    $dst = '57' . $row['tel_celular'];
    $msg = str_replace('%saldo%', number_format($row['saldo_a']), $tpl);
    echo "\n[] Send message to {$dst}: {$msg}\n";
    $wa->sendMessage($dst, $msg);
    $wa->sendMessageImage($dst, "pse.jpg");
    //$wa->sendGetRequestLastSeen($dst);
    sleep($seconds);
}
/*
echo "\n[] Request last seen $dst: ";

$wa->sendGetRequestLastSeen($dst);



echo "\n[] Send message to $dst: $msg\n";
$wa->sendMessage($dst , $msg);
echo "\n";
 * */
コード例 #11
0
do the following in a endless loop
due to the fact that we have no 
cronjob or anything similar to
start a job automatically
*/
while (true) {
    /*
      get Timestamp for today
    */
    $time = date('H:i', time());
    // 10:00
    $today = date('d-m-Y ', time());
    /**
    	  only send a message with new daily texts 
    	  if time is 08 o clock
    	 **/
    if (strcmp($time, "08:00") == 0) {
        $dailyTexts = new DailyTexts($today);
        $msg = "Losung fuer den " . $today . "\n" . "Watchword: " . $dailyTexts->getWatchword() . "\n" . "Doctrine: " . $dailyTexts->getDoctrine() . "\n";
        echo $msg;
        /**
        		  Sending message to the group with the daily dext:
        		  Where $gId is the group id.
        		 **/
        $w->sendMessage($gId, $msg);
        //sleep for 23 hours
        //sleep(23*60*60);
    }
    sleep(59);
    $w->sendPing();
}
コード例 #12
0
ファイル: watracker.php プロジェクト: fabiand93/WA-Tracker
    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 {
    echo "- The user is offline\n\n";
}
$lastpresence = "";
while (true) {
    $wa->pollMessage();
    if ($lastpresence == "available" && $presence == "unavailable") {
        $timeOffline = date("Y-m-d H:i:s");
        while ($presence == "unavailable") {
            $timeDiff = round(strtotime(date("Y-m-d H:i:s")) - strtotime($timeOffline));
            echo secondsToTime($timeDiff) . "\n";
            if ($notify != "") {
                $wa->sendMessage($notify, "({$target}) " . secondsToTime($timeDiff));
            }
            $wa->pollMessage();
            sleep($time);
        }
    }
    $lastpresence = $presence;
    sleep($time);
}
コード例 #13
0
 public function send_whatsapp_msg()
 {
     if (!empty($_FILES['image']['name'][0])) {
         $this->upload_files('image');
         exit;
     }
     if (!empty($_FILES['audio']['name'][0])) {
         $this->upload_files('audio');
     }
     if (!empty($_FILES['video']['name'][0])) {
         $this->upload_files('video');
         exit;
     }
     if ($this->input->post('doSend')) {
         require_once 'business_services/whatsapp/vendor/autoload.php';
         $username = $this->config->item('WhatsAppNumber');
         //Mobile Phone prefixed with country code so for india it will be 91xxxxxxxx
         $password = $this->config->item('WhatsAppPassword');
         $w = new WhatsProt($username, 'Mahajyothis', "Mahajyothis", true);
         //Name your application by replacing "WhatsApp Messaging"
         $w->connect();
         $w->loginWithPassword($password);
         $target = $this->input->post('reciepient');
         //Target Phone,reciever phone
         $message = $this->input->post('message');
         $location = $this->input->post('location');
         $latitude = $this->input->post('latitude');
         $longitude = $this->input->post('longitude');
         $w->SendPresenceSubscription($target);
         //Let us first send presence to user
         if ($latitude && $longitude) {
             $w->sendBroadcastLocation($target, $latitude, $longitude, $location);
             // Send Location
         }
         if ($message) {
             $w->sendMessage($target, $message);
         }
         // Send Message
         $this->send_files($w, $target);
         echo json_decode(1);
         exit;
     }
 }
コード例 #14
0
ファイル: pollMessage.php プロジェクト: elepanda84/dutyPhone
}
for ($loop = 0; $loop < 9; $loop++) {
    $w->pollMessage();
    $dir = new DirectoryIterator(dirname($poll_dir . '*'));
    foreach ($dir as $fileinfo) {
        if (!$fileinfo->isDot()) {
            $dmsg = file_get_contents($poll_dir . $fileinfo->getFilename());
            $dnum = strtok($dmsg, "\n");
            $dmsg = substr(strstr($dmsg, "\n"), 1);
            if ($dnum != '' && $dmsg != '') {
                if ($dnum[0] == '+') {
                    //Job file contains a properly formatted number starting with a +
                    $dnum = ltrim($dnum, '+');
                    //Remove + because WA servers dont like it
                    echo 'Send to: ' . $dnum . '#' . $dmsg . "\n";
                    $w->sendMessage($dnum, $dmsg);
                    mysql_query("INSERT INTO `messages` VALUES (NULL, NOW(), 'WA-API', '{$dnum}', '{$dmsg}')");
                } else {
                    if ($dnum == 'DUTYNUM') {
                        //Send to duty number only
                        $dnum = getDutyNumber();
                        if ($dnum[0] == '+') {
                            $dnum = ltrim($dnum, '+');
                        }
                        echo 'Send to: ' . $dnum . '#' . $dmsg . "\n";
                        $w->sendMessage($dnum, $dmsg);
                        mysql_query("INSERT INTO `messages` VALUES (NULL, NOW(), 'WA-API', '{$dnum}', '{$dmsg}')");
                    } else {
                        if ($dnum == 'GROUPCHAT') {
                            $gc = getGroupChats();
                            while ($row = mysql_fetch_array($gc)) {
コード例 #15
0
ファイル: socket.php プロジェクト: uiugor/INS_API-s
$w->SendPresenceSubscription($target);
//TODO: presense handling (online/offline/typing/last seen)
while (running($time)) {
    while ($w->pollMessage()) {
    }
    running($time);
    //check again if timestamp has been updated
    //check for outbound messages to send:
    session_start();
    $outbound = $_SESSION['outbound'];
    $_SESSION['outbound'] = [];
    session_write_close();
    if (count($outbound) > 0) {
        foreach ($outbound as $message) {
            //send messages
            $w->sendMessage($message['target'], $message['body']);
            $w->pollMessages();
        }
    }
    //check for received messages:
    $messages = $w->getMessages();
    if (count($messages) > 0) {
        session_start();
        $inbound = $_SESSION['inbound'];
        $_SESSION['inbound'] = [];
        //lock
        foreach ($messages as $message) {
            $data = @$message->getChild('body')->getData();
            if ($data != null && $data != '') {
                $inbound[] = $data;
            }
コード例 #16
0
    $file_size = $_FILES['image']['size'];
    $file_tmp = $_FILES['image']['tmp_name'];
    $file_type = $_FILES['image']['type'];
    $file_ext = strtolower(end(explode('.', $_FILES['image']['name'])));
    $extensions = array("jpeg", "jpg", "png", "gif");
    if (in_array($file_ext, $extensions) === false) {
        $errors[] = "extension not allowed, please choose a JPEG or PNG file.";
    }
    if ($file_size > 2097152) {
        $errors[] = 'File size must be excately 2 MB';
    }
    if (empty($errors) == true) {
        move_uploaded_file($file_tmp, "demo/" . $file_name);
        echo "Success";
    } else {
        print_r($errors);
    }
}
// $img = $_POST['img'];
// $target = $receiver; //Target Phone,reciever phone
// $message = $message;
$filepath = "demo/" . $file_name;
// $pathToVideo = "media/Canon.mp4";
// $w->SendPresenceSubscription($target); //Let us first send presence to user
$w->sendMessage($receiver, $message);
// Send Message
$w->sendMessageImage($receiver, $filepath);
// $w->sendMessageVideo($receiver, $pathToVideo);
$w->pollMessage();
echo 'Message Sent Successfully';
header("Location: send.php?success=1");
コード例 #17
0
ファイル: whatsapp.php プロジェクト: mustafabicer/elggplugins
        $wa->connect();
        $wa->loginWithPassword($group->whatsapp_password);
        // $wa->sendSetProfilePicture($group->getIconURL());
        $wa->sendMessage($_POST['testmobile'], "You have done it,Visit http://enraiser.com visit  http://Kindit.org ");
        for ($i = 0; $i < 5; $i++) {
            $wa->pollMessages();
        }
        $content = "check now";
    } elseif ($step == '5') {
        require elgg_get_plugins_path() . 'enriver/vendors/whatsapi/whatsprot.class.php';
        $wa = new WhatsProt($group->whatsapp_mobile, $group->whatsapp_imei, $group->whatsapp_name, false);
        $wa->connect();
        $wa->loginWithPassword($group->whatsapp_password);
        $members = $group->getMembers();
        foreach ($members as $member) {
            if ($member->mobile and $member->mobile != "") {
                $targets[] = $member->mobile;
                $wa->sendMessage($member->mobile, $_POST['groupmessage']);
            }
        }
        for ($i = 0; $i < 5; $i++) {
            $wa->pollMessages();
        }
        $content = "check now";
        $content = "<h2 class='elgg-heading-main'>done</h2><br><br>";
    }
} else {
    $content = "<h2 class='elgg-heading-main'>No permission</h2><br><br>";
}
$body = elgg_view_layout('one_sidebar', array('content' => $content, 'sidebar' => $sidebar));
echo elgg_view_page("", $body);
コード例 #18
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();
コード例 #19
0
ファイル: whatsapp.php プロジェクト: diamondobama/WhatsAPI
                $command = trim(strstr($line, ' ', TRUE));
            } else {
                $command = $line;
            }
            switch ($command) {
                case "/query":
                    $dst = trim(strstr($line, ' ', FALSE));
                    echo "[] Interactive conversation with {$dst}:\n";
                    break;
                case "/lastseen":
                    echo "[] Request last seen {$dst}: ";
                    $wa->sendGetRequestLastSeen($dst);
                    break;
                default:
                    echo "[] Send message to {$dst}: {$line}\n";
                    $wa->sendMessage($dst, $line);
                    break;
            }
        }
    }
    exit(0);
}
if ($_SERVER['argv'][1] == "-l") {
    echo "\n[] Listen mode:\n";
    while (TRUE) {
        $wa->pollMessages();
        $data = $wa->getMessages();
        if (!empty($data)) {
            print_r($data);
        }
        sleep(1);
コード例 #20
0
ファイル: whatsapp.php プロジェクト: HeberPcL/WhatsAppBot
require_once 'ProcessNode.class.php';
$target = '919676376541';
$w = new WhatsProt($userPhone, $userName, $debug);
$w->Connect();
$w->LoginWithPassword($password);
//$w->eventManager()->bind("onGetMessage", "onMessage");
$w->eventManager()->bind("onPresenceAvailable", "onPresenceAvailable");
$w->eventManager()->bind("onPresenceUnavailable", "onPresenceUnavailable");
$w->eventManager()->bind("onGetProfilePicture", "onGetProfilePicture");
$w->sendGetProfilePicture($target, true);
echo "[*] Connected to WhatsApp\n\n";
//update your profile picture
//$w->sendSetProfilePicture("demo/foglet.jpg");
//send picture
//$w->sendMessageImage($target, "demo/foglet.jpg");
$w->sendMessage($target, "Guess the number :)");
$pn = new ProcessNode($w, $target);
$w->setNewMessageBind($pn);
while (!file_exists("stopRunning")) {
    while ($w->pollMessage()) {
    }
    /*
    	$messages = $w->getMessages();
    
    	foreach ($messages as $message){
    		$from = $message->getAttribute("from");
    		if($message->getChild("body")){
    			$body = $message->getChild("body")->getData();
    			echo 'this is body '.$body;
    		}
    
コード例 #21
0
ファイル: perfil.php プロジェクト: aristofanio/WhatsApp-Tools
<?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;
    // extract days
    $days = floor($seconds / $secondsInADay);
    // extract hours
    $hourSeconds = $seconds % $secondsInADay;
    $hours = floor($hourSeconds / $secondsInAnHour);
コード例 #22
0
ファイル: pollMessage.php プロジェクト: jeromez80/dutyPhone
$GLOBALS["online_contacts"] = array();
$GLOBALS["current_contact"];
$pn = new ProcessNode($w, $contact);
$w->setNewMessageBind($pn);
$w->pollMessage();
$msgs = $w->getMessages();
foreach ($msgs as $m) {
    # process inbound messages
    #print($m->NodeString("") . "\n");
}
for ($loop = 0; $loop < 9; $loop++) {
    sleep(5);
    $w->pollMessage();
    $result = mysql_query("SELECT Job_ID, Job_Time, Job_Type, Dest_CtyCode, Dest_Number, Dest_Message FROM `OutMessageQueue` WHERE Job_Type='WA'");
    while ($msg = mysql_fetch_array($result)) {
        $w->sendMessage($msg['Dest_CtyCode'] . $msg['Dest_Number'], $msg['Dest_Message']);
        mysql_query("INSERT INTO `OutMessageCompleted` (Job_ID, Job_Time, Job_Type, Dest_CtyCode, Dest_Number, Dest_Message) VALUES (NULL, NULL, 'WA', '" . $msg['Dest_CtyCode'] . "', '" . $msg['Dest_Number'] . "', '" . $msg['Dest_Message'] . "')");
        mysql_query("DELETE FROM `OutMessageQueue` WHERE Job_ID='" . $msg['Job_ID'] . "'");
    }
    /******
    				mysql_query("INSERT INTO `messages` VALUES (NULL, NOW(), 'WA-API', '$dnum', '$dmsg')");
    				$gc = getGroupChats();
    				while ($row = mysql_fetch_array($gc)) {
    					$dnum=$row['group_code'];
    					echo 'Send to: '.$dnum . '#'. $dmsg."\n";
    					mysql_query("INSERT INTO `messages` VALUES (NULL, NOW(), 'WA-API', '".$row['group_names']."', '$dmsg')");
    					$w->sendMessage($dnum, $dmsg);
    	*********/
}
//for loop
$w->disconnect();
コード例 #23
0
//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
$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');
//send Location
//$w->sendMessageLocation($target, '4.948568', '52.352957');
// Implemented out queue messages and auto msgid
$w->sendMessage($target, 'Guess the number :)');
$w->sendMessage($target, 'Sent from WhatsApi at ' . date('H:i'));
while ($w->pollMessage()) {
}
/*
 * You can create a ProcessNode class (or whatever name you want) that has a process($node) function
 * and pass it through setNewMessageBind, that way everytime the class receives a text message it will run
 * the process function to it.
 */
$pn = new ProcessNode($w, $target);
$w->setNewMessageBind($pn);
echo "\n\nYou can also write and send messages to {$target} (interactive conversation)\n\n> ";
while (1) {
    $w->pollMessage();
    $msgs = $w->getMessages();
    foreach ($msgs as $m) {
コード例 #24
0
ファイル: bot.php プロジェクト: dpmika/php-bot
$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
        $node = new ProcessNode();
        $messaggio = $node->process($m);
        $messaggioTesto = strtolower($messaggio['testo']);
        if ($messaggioTesto == strtolower($nickname . " che fai?")) {
            $risposta = chefai($messaggio);
            $target = $messaggio['from'];
            $w->sendMessage($target, $risposta);
        } else {
            if ($messaggioTesto == strtolower($nickname . " perla")) {
                $risposta = barzellette($messaggio);
                $target = $messaggio['from'];
                $w->sendMessage($target, $risposta);
            } else {
                if ($messaggioTesto == strtolower($nickname . " dammi un numero")) {
                    $risposta = numero($messaggio);
                    $target = $messaggio['from'];
                    $w->sendMessage($target, $risposta);
                } else {
                    if ($messaggioTesto == strtolower($nickname . " chi sei?")) {
                        $risposta = chisei($messaggio);
                        $target = $messaggio['from'];
                        $w->sendMessage($target, $risposta);
コード例 #25
0
//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');
//send Location
//$w->sendLocation($target, '4.948568', '52.352957');
// Implemented out queue messages and auto msgid
$w->sendMessage($target, "Sent from WhatsApi at " . time());
/**
 * You can create a ProcessNode class (or whatever name you want) that has a process($node) function
 * and pass it through setNewMessageBind, that way everytime the class receives a text message it will run
 * the process function to it.
 */
$pn = new ProcessNode($w, $target);
$w->setNewMessageBind($pn);
while (1) {
    $w->pollMessages();
    $msgs = $w->getMessages();
    foreach ($msgs as $m) {
        # process inbound messages
        //print($m->NodeString("") . "\n");
    }
}
コード例 #26
0
ファイル: client.php プロジェクト: MattPorto/Chat-API
                     echo "==================\n\n";
                     echo "/query      - Shows the number you are chatting with\n";
                     echo "/lastseen   - Last seen of the user\n";
                     echo "/block      - Blocks the user\n";
                     echo "/unblock    - Unblocks user\n";
                     echo "/time       - Current time\n";
                     echo "/back       - Return to main menu\n\n";
                     break;
                 default:
                     $w->sendMessagePaused($contact);
                     if (!filter_var($line, FILTER_VALIDATE_URL) === false) {
                         if (@getimagesize($line) !== false) {
                             $w->sendMessageImage($contact, $line);
                         }
                     } else {
                         $w->sendMessage($contact, $line);
                     }
                     $compose = true;
                     break;
             }
         }
     }
     break;
 case '/time':
     echo date("l jS \\of F Y h:i:s A") . "\n\n";
     break;
 case '/help':
     echo "Available commands\n";
     echo "==================\n\n";
     echo "/add      - Adds a contact\n";
     echo "/delete   - Removes a contact\n";
コード例 #27
0
        if (strrchr($line, ' ')) {
            $command = trim(strstr($line, ' ', true));
        } else {
            $command = $line;
        }
        switch ($command) {
            case '/query':
                $dst = trim(strstr($line, ' ', false));
                echo "[] Interactive conversation with {$contact}:\n";
                break;
            case '/lastseen':
                echo "[] Last seen {$target}: ";
                $w->sendGetRequestLastSeen($target);
                break;
            default:
                $w->sendMessage($target, $line);
                break;
        }
    }
}
class ProcessNode implements NewMsgBindInterface
{
    protected $wp = false;
    protected $target = false;
    public function __construct($wp, $target)
    {
        $this->wp = $wp;
        $this->target = $target;
    }
    public function process(\ProtocolNode $node)
    {
コード例 #28
0
echo "[*] Logging in as WhatsApp Tracker ({$sender})\n";
$wa = new WhatsProt($sender, 'WhatsApp Tracker', FALSE);
$wa->connect();
$wa->loginWithPassword($password);
$events = new MyEvents($wa);
$wa->eventManager()->bind('onGetRequestLastSeen', 'onGetRequestLastSeen');
$wa->eventManager()->bind("onPresenceAvailable", "onPresenceAvailable");
$wa->eventManager()->bind("onPresenceUnavailable", "onPresenceUnavailable");
if ($_SERVER['argv'][1] == "-cRemote0" || $_SERVER['argv'][1] == "-check") {
    echo "\n[-] Tracker mode (ON):\n";
    while (TRUE) {
        if ($_SERVER['argv'][1] == "-check") {
            $wa->sendGetRequestLastSeen($dst);
        } else {
            $wa->sendGetRequestLastSeen($_SERVER['argv'][3]);
            $wa->sendMessage($dst, "(" . $_SERVER['argv'][3] . ") " . $ls);
        }
        sleep(60);
    }
}
if ($_SERVER['argv'][1] == "-cHidden" || $_SERVER['argv'][1] == "-cRemote1") {
    echo "\n[-] Tracker mode (ON): Waiting the user to get online...\n";
    $wa->SendPresenceSubscription($dst);
    $wa->pollMessage();
    if ($presence == "available") {
        echo "- The user is now online\n\n";
    } else {
        echo "- The user is offline\n\n";
    }
    while (true) {
        $wa->pollMessage();