Carga y configuración de platilla de api de whats app
This commit is contained in:
@@ -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',
|
||||
@@ -92,8 +92,27 @@ class WhatsAppService
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
public function procesarOptOut(string $telefono): void
|
||||
{
|
||||
$normalizado = $this->normalizarTelefono($telefono);
|
||||
|
||||
Reference in New Issue
Block a user