RESUMEN: Traigo un tema super interesante y me gustaria saber como establecer conexión desde Calc para el envio de sms a traves de un proveedor de servicios de SMS.
Me gustaria conectar con LibreOffice CALC a una http API para poder enviar sms con Calc.
Tengo un servicio contratado con un proveedor xxx.com para el envio de sms y con su api puedo enviar sms a traves de Excel.
Pero ahora necesito hacerlo con Calc de libre Office y como este software libre usa OOoBasic (otro Basic) no se muy bien como son las funciones, objetos o metodos a los que he de llamar.
Adjunto mi codigo en Excel, alguien sabe como conectar con esta API via http, URL ?
Las lineas que ME INTERESA SABER SON las siguientes:
Código: Seleccionar todo
'**** Conect to the API via Htpp ****************
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0") 'Create Object
oXMLHTTP.Open "GET", RouteHtml
oXMLHTTP.Send
Send_SMS = oXMLHTTP.responseText 'The sms provider give us a feedback to know if all went fine.
'** Clean the object *********
Set oXMLHTTP = Nothing
Agradecería un ejemplo del codigo descrito arriba. El codigo completo PARA EXCEL lo pongo aqui abajo. GRACIAS !!
Código: Seleccionar todo
Function Send_SMS(sMobileNumbers As String)
'Send sms via Excel. For this you will have to activate Reference -> Microsoft XML v6.0 in menu VBA Tools/References/ (Activate library VBA Microsoft XML v6.0)
'You can send sms with excel. Send one o several sms. If you want to send same text to several telephones numbers, you must separate each telephone with a coma.
'For instance: sMobileNumbers = "49123456789,32123456789,34123456789"
'*** Este macro es para Excel ******************
Dim SmsOperator_Provider As String
Dim oXMLHTTP As Object
Dim Result As String
Dim RouteHtml As String
Dim sUrl As String
Dim sAPI_ID As String
Dim sPassword As String
Dim sUsername As String
Dim sTelefonFrom As String
Dim sSenderId As String
Dim Text_Sms As String
Dim sreq_feat As String
'***** Get tHe data from our EXCEL Sheet **************
sTelefonFrom = Worksheets("Sms").Range("B4").Value
Text_Sms = Worksheets("Sms").Range("C4").Value
SmsOperator_Provider = Worksheets("Sms").Range("C2").Value 'NAME from our Sms operator.
sUrl = Worksheets("Sms").Range("B10").Value
sUsername = Worksheets("Sms").Range("B11").Value
sPassword = Worksheets("Sms").Range("B12").Value
sAPI_ID = Worksheets("Sms").Range("B13").Value 'id de registro API en proveedor de sms
sSenderId = Worksheets("Sms").Range("B14").Value 'id del que envia el sms.
sreq_feat = Worksheets("Sms").Range("B15").Value 'Es el requisito que se pone al enlace para que salga el id sender en el sms.
'***** Concatenate the http API pattern '*********
'https://www.smsdiscount.com/myaccount/sendsms.php?username=xxxxxxxxxx&password=xxxxxxxxxx&from=xxxxxxxxxx&to=xxxxxxxxxx&text=xxxxxxxxxx
'For several clients the variable must be like this: sMobileNumbers = "+34123456789,+34123456789,+34123456789"
RouteHtml = sUrl
RouteHtml = RouteHtml & "username=" & sUsername
RouteHtml = RouteHtml & "&password=" & sPassword
RouteHtml = RouteHtml & "&from=" & sTelefonFrom
RouteHtml = RouteHtml & "&to=" & sMobileNumbers
RouteHtml = RouteHtml & "&text=" & Text_Sms
'**** Conect to the API via Htpp ****************
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0") 'Create Object
oXMLHTTP.Open "GET", RouteHtml
oXMLHTTP.Send
'*** Get the feedback from SMS_Provider **************
'Usually they provide some information to know whether sms was send successfully or not.
Send_SMS = oXMLHTTP.responseText 'The sms provider give us a feedback to know if all went fine.
'** Clean the object *********
Set oXMLHTTP = Nothing
End Function