本文整理汇总了PHP中WhatsProt::sendMessageImage方法的典型用法代码示例。如果您正苦于以下问题:PHP WhatsProt::sendMessageImage方法的具体用法?PHP WhatsProt::sendMessageImage怎么用?PHP WhatsProt::sendMessageImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhatsProt
的用法示例。
在下文中一共展示了WhatsProt::sendMessageImage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: fclose
fclose($fp);
}
}
//Create the whatsapp object and setup a connection.
$w = new WhatsProt($username, $identity, $nickname, $debug);
$w->connect();
// Now loginWithPassword function sends Nickname and (Available) Presence
$w->loginWithPassword($password);
//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);
示例4: date
$w->connect();
// Now loginWithPassword function sends Nickname and (Available) Presence
$w->loginWithPassword($password);
//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);
//Print when the user goes online/offline (you need to bind a function to the event onPressence
//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.
示例5: findNicknameByPhone
$nickname = findNicknameByPhone($contact);
echo "[] Interactive conversation with {$nickname}:\n";
break;
case '/lastseen':
echo "[] Last seen {$contact}: ";
$w->sendMessagePaused($contact);
$compose = true;
$w->sendPresenceSubscription($contact);
break;
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";
示例6: date
break;
case '/help':
echo "Available commands\n";
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";
示例7: strtolower
$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");
示例8: 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";
* */
示例9: WhatsProt
<?php
require_once '../whatsprot.class.php';
$username = "436646473355";
//Mobile Phone prefixed with country code so for india it will be 91xxxxxxxx
$password = "Z10t1ePNG1CsjZy5hrnHgXm/v1g=";
$w = new WhatsProt($username, 0, "ADarkHero Whatsapp Bot", true);
//Name your application by replacing "WhatsApp Messaging"
$w->connect();
$w->loginWithPassword($password);
$to = "436605635662";
$filepath = "testImage.png";
// This could be url or path to video.
$w->SendPresenceSubscription($to);
//Let us first send presence to user
$w->sendMessageImage($to, $filepath, false, 0, "", "");
// Send Message
$w->pollMessage();