fix(wa): enviar botón URL como componente button/url, no como header
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7a56ec25a0
commit
735d70dc50
+12
-1
@@ -191,7 +191,18 @@ if (isset($_GET['test_cel'])) {
|
|||||||
require_once __DIR__ . '/services/WhatsAppService.php';
|
require_once __DIR__ . '/services/WhatsAppService.php';
|
||||||
try {
|
try {
|
||||||
$wa = new WhatsAppService('turnero');
|
$wa = new WhatsAppService('turnero');
|
||||||
$wa->sendTemplateMessage($testCel, $testTpl, $testLang, ['A001'], [$testLink]);
|
$rawComps = [
|
||||||
|
['type' => 'body', 'parameters' => [['type' => 'text', 'text' => 'A001']]]
|
||||||
|
];
|
||||||
|
if ($testLink) {
|
||||||
|
$rawComps[] = [
|
||||||
|
'type' => 'button',
|
||||||
|
'sub_type' => 'url',
|
||||||
|
'index' => '0',
|
||||||
|
'parameters' => [['type' => 'text', 'text' => $testLink]],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$wa->sendTemplateMessage($testCel, $testTpl, $testLang, [], [], $rawComps);
|
||||||
echo "✅ Mensaje enviado a {$testCel}\n";
|
echo "✅ Mensaje enviado a {$testCel}\n";
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
echo "❌ Error: " . $e->getMessage() . "\n";
|
echo "❌ Error: " . $e->getMessage() . "\n";
|
||||||
|
|||||||
@@ -184,13 +184,18 @@ try {
|
|||||||
$nombreWA = $pacienteNombre ?: 'Paciente';
|
$nombreWA = $pacienteNombre ?: 'Paciente';
|
||||||
try {
|
try {
|
||||||
$wa = new WhatsAppService('turnero');
|
$wa = new WhatsAppService('turnero');
|
||||||
$wa->sendTemplateMessage(
|
$rawComps = [
|
||||||
$cel,
|
['type' => 'body', 'parameters' => [['type' => 'text', 'text' => $codigo]]]
|
||||||
$waTemplate,
|
];
|
||||||
$waLang,
|
if ($enlaceConsentimiento) {
|
||||||
[$codigo],
|
$rawComps[] = [
|
||||||
$enlaceConsentimiento ? [$enlaceConsentimiento] : []
|
'type' => 'button',
|
||||||
);
|
'sub_type' => 'url',
|
||||||
|
'index' => '0',
|
||||||
|
'parameters' => [['type' => 'text', 'text' => $enlaceConsentimiento]],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$wa->sendTemplateMessage($cel, $waTemplate, $waLang, [], [], $rawComps);
|
||||||
} catch (\Throwable $eTmpl) {
|
} catch (\Throwable $eTmpl) {
|
||||||
try {
|
try {
|
||||||
$msg = "Hola {$nombreWA}, su turno *{$codigo}* ha sido registrado.";
|
$msg = "Hola {$nombreWA}, su turno *{$codigo}* ha sido registrado.";
|
||||||
|
|||||||
Reference in New Issue
Block a user