Imports System.Net.
Http
Imports System.Text
Imports Newtonsoft.Json.Linq
Module Module1
Sub Main()
Dim phoneId As String = "Tu_Id_Telefonico"
Dim token As String = "Tu_Token"
Dim client = New HttpClient()
client.DefaultRequestHeaders.Authorization = New
System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token)
System.Net.ServicePointManager.SecurityProtocol =
System.Net.SecurityProtocolType.Tls12
Dim json = New JObject()
json.Add("recipient_type", "individual")
json.Add("to", "Tu_Numero_Destino")
json.Add("type", "template")
json.Add("template", New JObject From {
{"name", "Tu_Nombre_De_Plantilla"},
{"language", New JObject From {
{"code", "Tu_Codifocacion_De_Lenguaje_De_Plantilla"}
}},
{"components", New JArray From {
New JObject From {
{"type", "header"},
{"parameters", New JArray From {
New JObject From {
{"type", "text"},
{"text", "Tu_Parametro_1"}
}
}}
},
New JObject From {
{"type", "body"},
{"parameters", New JArray From {
New JObject From {
{"type", "text"},
{"text", "Tu_Parametro_1"}
},
New JObject From {
{"type", "text"},
{"text", "Tu_Parametro_2"}
},
New JObject From {
{"type", "text"},
{"text", "Tu_Parametro_3"}
},
New JObject From {
{"type", "text"},
{"text", "Tu_Parametro_4"}
}
}}
}
}}
})
json.Add("messaging_product", "whatsapp")
Dim response = client.PostAsync("https://graph.facebook.com/v16.0/" &
phoneId & "/messages", New StringContent(json.ToString(), Encoding.UTF8,
"application/json")).Result
If response.IsSuccessStatusCode Then
Console.WriteLine("El mensaje se ha enviado correctamente.")
Console.ReadKey()
Else
Console.WriteLine("Se produjo un error al enviar el mensaje: " &
response.Content.ReadAsStringAsync().Result)
Console.ReadKey()
End If
End Sub
End Module