-- cambio para obtener el token desde archivo
This commit is contained in:
@@ -628,24 +628,38 @@ Namespace Extensiones
|
|||||||
Return String.Format("<li><a href=""{4}"" {5}>{0}<span class=""details""><span class=""label label-sm label-icon label-{1}""><i class=""{2}""></i></span>{3}</span></a></li>", Time, Tipo, Ico, Mensaje, Link, If(tonewpage, "target=""_blank""", ""))
|
Return String.Format("<li><a href=""{4}"" {5}>{0}<span class=""details""><span class=""label label-sm label-icon label-{1}""><i class=""{2}""></i></span>{3}</span></a></li>", Time, Tipo, Ico, Mensaje, Link, If(tonewpage, "target=""_blank""", ""))
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function EnviarNotificacionWhatsApp(NumeroTelefono As String, Mensaje As String) As Boolean
|
Public Function EnviarNotificacionWhatsApp(NumeroTelefono As String, Mensaje As String, Optional NombrePlantilla As String = "") As Boolean
|
||||||
Dim RetornoObj As String = "{}"
|
Dim RetornoObj As String = "{}"
|
||||||
Dim Retorno As Boolean = False
|
Dim Retorno As Boolean = False
|
||||||
|
Dim Str As String = My.Computer.FileSystem.ReadAllText($"c:\temp\WSToken.txt")
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Dim TokenAutorizacion As String = "Bearer EAAVcZB36KfEEBO0OlN5ZAUPhNAUZCsHuMbpeVrrxZCJZAacLgBMOXXXcyA6aLEbbANMjbeTuJbsZC4IAvsZBwEALCYqc7oZCrnHF67sc0RYMBru9R0YKBFhi8gFjZAhJgoCJauBdZA30R9YPXZA2ZByQZAKclRCL20VLu74HEtw3YKu1MiG1vEsZANWJZAHhcJCUANUs3zIMFvoC6dBoJgQsABEZAYYZD"
|
Dim TokenAutorizacion As String = $"Bearer {Str}"
|
||||||
Using httpClient = New HttpClient()
|
Using httpClient = New HttpClient()
|
||||||
Using request = New HttpRequestMessage(HttpMethod.Post, New Uri("https://graph.facebook.com/v20.0/263533173499868/messages"))
|
Using request = New HttpRequestMessage(HttpMethod.Post, New Uri("https://graph.facebook.com/v20.0/400260286507131/messages"))
|
||||||
|
|
||||||
request.Headers.Add("Authorization", TokenAutorizacion)
|
request.Headers.Add("Authorization", TokenAutorizacion)
|
||||||
Dim json = New Newtonsoft.Json.Linq.JObject()
|
Dim json = New Newtonsoft.Json.Linq.JObject()
|
||||||
json.Add(New Newtonsoft.Json.Linq.JProperty("messaging_product", "whatsapp"))
|
json.Add(New Newtonsoft.Json.Linq.JProperty("messaging_product", "whatsapp"))
|
||||||
json.Add(New Newtonsoft.Json.Linq.JProperty("to", NumeroTelefono))
|
json.Add(New Newtonsoft.Json.Linq.JProperty("to", NumeroTelefono))
|
||||||
json.Add(New Newtonsoft.Json.Linq.JProperty("type", "text"))
|
If NombrePlantilla <> "" Then
|
||||||
Dim msgtexto As New Newtonsoft.Json.Linq.JObject(
|
json.Add(New Newtonsoft.Json.Linq.JProperty("type", "template"))
|
||||||
New Newtonsoft.Json.Linq.JProperty("preview_url", "true"),
|
Dim msgtexto As New Newtonsoft.Json.Linq.JObject(
|
||||||
New Newtonsoft.Json.Linq.JProperty("body", Mensaje.Replace("<br/>", "\n"))
|
New Newtonsoft.Json.Linq.JProperty("name", NombrePlantilla),
|
||||||
)
|
New Newtonsoft.Json.Linq.JProperty("language",
|
||||||
json.Add(New Newtonsoft.Json.Linq.JProperty("text", msgtexto))
|
New Newtonsoft.Json.Linq.JObject(
|
||||||
|
New Newtonsoft.Json.Linq.JProperty("code", "en_US"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
json.Add(New Newtonsoft.Json.Linq.JProperty("template", msgtexto))
|
||||||
|
Else
|
||||||
|
json.Add(New Newtonsoft.Json.Linq.JProperty("type", "text"))
|
||||||
|
Dim msgtexto As New Newtonsoft.Json.Linq.JObject(
|
||||||
|
New Newtonsoft.Json.Linq.JProperty("preview_url", "true"),
|
||||||
|
New Newtonsoft.Json.Linq.JProperty("body", Mensaje.Replace("<br/>", "\n"))
|
||||||
|
)
|
||||||
|
json.Add(New Newtonsoft.Json.Linq.JProperty("text", msgtexto))
|
||||||
|
End If
|
||||||
|
|
||||||
Using content = New StringContent(json.ToString, Encoding.UTF8, "application/json")
|
Using content = New StringContent(json.ToString, Encoding.UTF8, "application/json")
|
||||||
request.Content = content
|
request.Content = content
|
||||||
@@ -667,6 +681,8 @@ Namespace Extensiones
|
|||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
#Region "files dropzone"
|
#Region "files dropzone"
|
||||||
|
|||||||
Reference in New Issue
Block a user