当前位置: 首页>>代码示例>>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;未经允许,请勿转载。