--activación envio whatsapp
This commit is contained in:
@@ -450,8 +450,8 @@ Namespace Extensiones
|
||||
ToastInformacion = 5 'succes
|
||||
ToastInformacionB = 6 'info
|
||||
ToastError = 7 'error
|
||||
ToastAdventencia = 8 'Warning
|
||||
|
||||
ToastAdventencia = 8 'Warning
|
||||
|
||||
End Enum
|
||||
<Runtime.CompilerServices.Extension()>
|
||||
Public Sub Alert(Obj As Object, Mensaje As String, pOpcion As TipoMensaje, Optional JSBtnAceptar As String = "", Optional TextoConfirmacion As String = "Aceptar", Optional TextoCancelacion As String = "Cancelar", Optional TimeoutToast As Integer = 5, Optional ShowCloseButton As Boolean = True, Optional TextoSegundoBoton As String = "", Optional JSBtn2 As String = "")
|
||||
@@ -619,6 +619,45 @@ 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""", ""))
|
||||
End Function
|
||||
|
||||
Public Function EnviarNotificacionWhatsApp(NumeroTelefono As String, Mensaje As String) As Boolean
|
||||
Dim RetornoObj As String = "{}"
|
||||
Dim Retorno As Boolean = False
|
||||
Try
|
||||
Dim TokenAutorizacion As String = "Bearer EAAVcZB36KfEEBO0OlN5ZAUPhNAUZCsHuMbpeVrrxZCJZAacLgBMOXXXcyA6aLEbbANMjbeTuJbsZC4IAvsZBwEALCYqc7oZCrnHF67sc0RYMBru9R0YKBFhi8gFjZAhJgoCJauBdZA30R9YPXZA2ZByQZAKclRCL20VLu74HEtw3YKu1MiG1vEsZANWJZAHhcJCUANUs3zIMFvoC6dBoJgQsABEZAYYZD"
|
||||
Using httpClient = New HttpClient()
|
||||
Using request = New HttpRequestMessage(HttpMethod.Post, New Uri("https://graph.facebook.com/v20.0/263533173499868/messages"))
|
||||
|
||||
request.Headers.Add("Authorization", TokenAutorizacion)
|
||||
Dim json = New Newtonsoft.Json.Linq.JObject()
|
||||
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("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))
|
||||
|
||||
Using content = New StringContent(json.ToString, Encoding.UTF8, "application/json")
|
||||
request.Content = content
|
||||
Dim response = httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).Result
|
||||
|
||||
If response.StatusCode = Net.HttpStatusCode.OK Then
|
||||
RetornoObj = response.Content.ReadAsStringAsync().Result
|
||||
Retorno = True
|
||||
End If
|
||||
End Using
|
||||
|
||||
End Using
|
||||
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
RetornoObj = New Newtonsoft.Json.Linq.JObject(New Newtonsoft.Json.Linq.JProperty("Error", ex.ToString())).ToString()
|
||||
GuardaLog("Ocurrió un error al enviar la informacion por whatsapp" & ex.Message)
|
||||
End Try
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "files dropzone"
|
||||
|
||||
Reference in New Issue
Block a user