Carga y configuración de platilla de api de whats app

This commit is contained in:
2026-05-22 22:22:36 -06:00
parent f99580c176
commit 19a236818e
2 changed files with 22 additions and 2 deletions
+2 -1
View File
@@ -22,7 +22,8 @@ RUN npm ci && \
npm run build
RUN mkdir -p storage/framework/sessions storage/framework/views storage/framework/cache storage/app/livewire-tmp storage/logs \
&& chmod -R 775 storage bootstrap/cache
&& chmod -R 775 storage bootstrap/cache \
&& chown -R nobody:nginx storage bootstrap/cache
RUN php artisan storage:link
+20 -1
View File
@@ -61,7 +61,7 @@ class WhatsAppService
return $response->json('messages.0.id');
}
public function enviarPromocion(string $telefono, Promocion $promocion): string
/*public function enviarPromocion(string $telefono, Promocion $promocion): string
{
$payload = [
'messaging_product' => 'whatsapp',
@@ -91,6 +91,25 @@ class WhatsAppService
throw new \RuntimeException($response->body());
}
return $response->json('messages.0.id');
}*/
public function enviarPromocion(string $telefono, Promocion $promocion): string
{
$response = Http::withToken($this->token)->post($this->apiUrl, [
'messaging_product' => 'whatsapp',
'to' => $this->normalizarTelefono($telefono),
'type' => 'template',
'template' => [
'name' => 'hello_world',
'language' => ['code' => 'en_US'],
],
]);
if ($response->failed()) {
throw new \RuntimeException($response->body());
}
return $response->json('messages.0.id');
}