up
This commit is contained in:
@@ -536,10 +536,62 @@ class WhatsAppService
|
||||
return $data['interactive']['body']['text'];
|
||||
}
|
||||
break;
|
||||
case 'reaction':
|
||||
return isset($data['reaction']['emoji']) ? $data['reaction']['emoji'] : json_encode($data['reaction']);
|
||||
}
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar reacción (emoji) a un mensaje previo
|
||||
* @param string $to Teléfono del destinatario
|
||||
* @param string $messageId ID del mensaje al que se reacciona
|
||||
* @param string $emoji Emoji de reacción
|
||||
* @param bool $dryRun Si true, no hace la petición y devuelve el payload
|
||||
*/
|
||||
public function sendReaction($to, $messageId, $emoji, $dryRun = false)
|
||||
{
|
||||
$data = [
|
||||
'messaging_product' => 'whatsapp',
|
||||
'to' => $this->formatPhoneNumber($to),
|
||||
'type' => 'reaction',
|
||||
'reaction' => [
|
||||
'message_id' => $messageId,
|
||||
'emoji' => $emoji
|
||||
]
|
||||
];
|
||||
|
||||
if ($dryRun) return $data;
|
||||
return $this->sendMessage($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar texto como respuesta (con contexto) a un mensaje existente
|
||||
* @param string $to Teléfono del destinatario
|
||||
* @param string $messageId ID del mensaje al que se responde
|
||||
* @param string $text Contenido del mensaje de respuesta
|
||||
* @param bool $preview_url Incluir preview_url en body.text
|
||||
* @param bool $dryRun Si true, no hace la petición y devuelve el payload
|
||||
*/
|
||||
public function sendTextReply($to, $messageId, $text, $preview_url = false, $dryRun = false)
|
||||
{
|
||||
$data = [
|
||||
'messaging_product' => 'whatsapp',
|
||||
'to' => $this->formatPhoneNumber($to),
|
||||
'type' => 'text',
|
||||
'context' => [
|
||||
'message_id' => $messageId
|
||||
],
|
||||
'text' => [
|
||||
'preview_url' => (bool)$preview_url,
|
||||
'body' => $text
|
||||
]
|
||||
];
|
||||
|
||||
if ($dryRun) return $data;
|
||||
return $this->sendMessage($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener usuario por teléfono
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user