當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WhatsProt::sendMessage方法代碼示例

本文整理匯總了PHP中WhatsProt::sendMessage方法的典型用法代碼示例。如果您正苦於以下問題:PHP WhatsProt::sendMessage方法的具體用法?PHP WhatsProt::sendMessage怎麽用?PHP WhatsProt::sendMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WhatsProt的用法示例。


在下文中一共展示了WhatsProt::sendMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sendMessage

 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;
 }
開發者ID:dFenille,項目名稱:whatsApi,代碼行數:14,代碼來源:ManagerWhatsModel.php

示例2: sendMessage

 /**
  * 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;
 }
開發者ID:djade007,項目名稱:WhatsApp,代碼行數:41,代碼來源:WhatsAppApi.php

示例3: sendWhatsapp

function sendWhatsapp($target, $message)
{
    $username = "972532243523";
    $password = "Wf5ZXzlpmLPQmPL0hqA4yxgu6L0=";
    $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);
}
開發者ID:moshew,項目名稱:A-Report_SERVER,代碼行數:17,代碼來源:send_whatsapp.php

示例4: execute

 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!</>');
 }
開發者ID:brenodouglas,項目名稱:wpp-cli,代碼行數:19,代碼來源:SendMessage.php

示例5: WhatsProt

<?php

require '../src/whatsprot.class.php';
$username = "2348139344522";
//Mobile Phone prefixed with country code so for india it will be 91xxxxxxxx
$password = "rB/U2CUy0u2rf3ZJ0zQNKb9FLWM=";
$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
開發者ID:Zetetikos,項目名稱:WhatsBulk,代碼行數:17,代碼來源:my_test.php

示例6: while

    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>
開發者ID:edmund88,項目名稱:whatsapi-enaijize,代碼行數:30,代碼來源:index.php

示例7: WhatsProt

// 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";
開發者ID:jl91,項目名稱:wasapbot,代碼行數:31,代碼來源:wasap-sendmsg.php

示例8: date

//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) {
開發者ID:takentaxi,項目名稱:Chat-API,代碼行數:31,代碼來源:exampleFunctional.php

示例9: running

//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;
            }
開發者ID:nekulin,項目名稱:WhatsAPI,代碼行數:31,代碼來源:socket.php

示例10: WhatsProt

$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";
 * */
開發者ID:eescallon,項目名稱:upload,代碼行數:31,代碼來源:sendwasa.php

示例11: date

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();
}
開發者ID:dgbass,項目名稱:MoravianDailyTexts,代碼行數:31,代碼來源:getLosungen.php

示例12: MyEvents

    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);
}
開發者ID:fabiand93,項目名稱:WA-Tracker,代碼行數:31,代碼來源:watracker.php

示例13: send_whatsapp_msg

 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;
     }
 }
開發者ID:Mahajyothis,項目名稱:Version1.0-Git,代碼行數:43,代碼來源:Business.php

示例14: DirectoryIterator

}
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)) {
開發者ID:elepanda84,項目名稱:dutyPhone,代碼行數:31,代碼來源:pollMessage.php

示例15: while

$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;
            }
開發者ID:uiugor,項目名稱:INS_API-s,代碼行數:31,代碼來源:socket.php


注:本文中的WhatsProt::sendMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。