本文整理汇总了PHP中WhatsProt::sendMessageVideo方法的典型用法代码示例。如果您正苦于以下问题:PHP WhatsProt::sendMessageVideo方法的具体用法?PHP WhatsProt::sendMessageVideo怎么用?PHP WhatsProt::sendMessageVideo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhatsProt
的用法示例。
在下文中一共展示了WhatsProt::sendMessageVideo方法的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: trim
case '/sendimage':
echo "\nEnter the URL or path of the image > ";
$filepath = trim(fgets(STDIN));
echo "\nSay something about the image > ";
$caption = trim(fgets(STDIN));
$target = $contact;
$w->sendMessageImage($target, $filepath, false, $fsize, $fhash, $caption);
$w->pollMessage();
break;
case '/sendvideo':
echo "\nEnter the URL or path of the video > ";
$filepath = trim(fgets(STDIN));
echo "\nSay something about the video > ";
$caption = trim(fgets(STDIN));
$target = $contact;
$w->sendMessageVideo($target, $filepath, false, $fsize, $fhash, $caption);
$w->pollMessage();
break;
////////////////////////// test ///////////////////
////////////////////////// test ///////////////////
case '/block':
echo "< User is now blocked >\n";
$w->sendMessagePaused($contact);
$compose = true;
$blocked = privacySettings($contact, 'block');
$w->sendSetPrivacyBlockedList($blocked);
break;
case '/unblock':
echo "< User is now unblocked >\n";
$w->sendMessagePaused($contact);
$compose = true;