本文整理汇总了PHP中WhatsProt::sendMessageAudio方法的典型用法代码示例。如果您正苦于以下问题:PHP WhatsProt::sendMessageAudio方法的具体用法?PHP WhatsProt::sendMessageAudio怎么用?PHP WhatsProt::sendMessageAudio使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhatsProt
的用法示例。
在下文中一共展示了WhatsProt::sendMessageAudio方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: sendFiles
/** IMPLEMENTS SEND MESSAGES **/
protected function sendFiles($to, $files)
{
set_time_limit(600);
$explode = explode('.', $files['image']['name']);
$extensao = end($explode);
$extensao = strtolower($extensao);
define('CAMINHO_MIDIA', 'c:/xampp5-6/htdocs/whatsApi/public/img/send-messages/');
if (in_array($extensao, array('3gp', 'mp4', 'mov', 'avi'))) {
$newName = md5($files['image']['name'] . date('Ymdhis')) . "." . $extensao;
$pathImage = CAMINHO_MIDIA . $newName;
$urlMain = $_SERVER['HTTP_ORIGIN'] . '/img/send-messages/' . $newName;
if (move_uploaded_file($files['image']['tmp_name'], $pathImage)) {
$this->managerWhats->sendMessageVideo($to, $urlMain);
$this->managerWhats->pollMessage();
} else {
$this->setLogTalk("Enviar image:" . $to, "Não foi possível enviar a mídia");
}
}
if (in_array($extensao, array('jpg', 'jpeg', 'gif', 'png'))) {
$newName = md5($files['image']['name'] . date('Ymdhis')) . "." . $extensao;
$pathImage = CAMINHO_MIDIA . $newName;
$urlMain = $_SERVER['HTTP_ORIGIN'] . '/img/send-messages/' . $newName;
if (move_uploaded_file($files['image']['tmp_name'], $pathImage)) {
$this->managerWhats->sendMessageImage($to, $urlMain);
$this->managerWhats->pollMessage();
} else {
$this->setLogTalk("Enviar image:" . $to, "Não foi possível enviar a mídia");
}
}
if (in_array($extensao, array('3gp', 'caf', 'wav', 'mp3', 'wma', 'ogg', 'aif', 'aac', 'm4a'))) {
$newName = md5($_FILES['image']['name'] . date('Ymdhis')) . "." . $extensao;
$pathImage = CAMINHO_MIDIA . $newName;
$urlMain = $_SERVER['HTTP_ORIGIN'] . '/img/send-messages/' . $newName;
if (move_uploaded_file($files['image']['tmp_name'], $pathImage)) {
$this->managerWhats->sendMessageAudio($to, $urlMain);
$this->managerWhats->pollMessage();
} else {
$this->setLogTalk("Enviar image:" . $to, "Não foi possível enviar a mídia");
}
}
return true;
}
示例3: chisei
if ($messaggioTesto == strtolower($nickname . " chi sei?")) {
$risposta = chisei($messaggio);
$target = $messaggio['from'];
$w->sendMessage($target, $risposta);
} else {
if ($messaggioTesto == strtolower($nickname . " cosa sai fare?")) {
$risposta = info($messaggio);
$target = $messaggio['from'];
$w->sendMessage($target, $risposta);
} else {
if ($messaggioTesto == strtolower($nickname . " musica")) {
$musica = new musica();
$target = $messaggio['from'];
$file = $musica->play();
$w->sendMessage($target, $file['title']);
$w->sendMessageAudio($target, $file['file'], false);
$w->pollMessage();
} else {
if (strstr($messaggioTesto, strtolower($nickname . " meteo "))) {
echo $messaggioTesto;
//Divido la frase per recuperare la città
$frase = explode(" ", $messaggioTesto);
$citta = $frase['2'];
//Istanzioni l'oggetto meteo
$meteo = new Meteo();
//Recupero le previsioni
$previsioni = $meteo->MeteoCitta($citta);
// Invio il messaggio con il meteo
$target = $messaggio['from'];
$w->sendMessage($target, $previsioni);
}