Hi to all!
I have to send sms from my application in this way Using Rest Api of our provider.
Using this command from ubuntu (in my windows10) it works fine
curl --location 'https://app.xxxxxxx.it/API/v1.0/REST/sms' \
--header 'user_key: 9999999' \
--header 'Access_token: TOKENALFANUMERICO' \
--header 'Content-Type: application/json' \
--data '{
"recipient": [
"+393123456789"
],
"message": "Ths is a Test",
"sender": "MarcoBoschi",
"message_type": "n"
}'
How can I launch this command from a fivewin program?
Many Thanks to all
Marco
Send sms POST
- MarcoBoschi
- Posts: 1070
- Joined: Thu Nov 17, 2005 11:08 am
- Location: Padova - Italy
- Contact:
Send sms POST
Marco Boschi
info@marcoboschi.it
info@marcoboschi.it
Re: Send sms POST
Hola Marco
Tal vez esto te pueda dar una luz
Yo lo uso para consumir una api
Tal vez esto te pueda dar una luz
Yo lo uso para consumir una api
Code: Select all | Expand
#include "Fivewin.ch"
static oOle
FUNCTION Main()
LOCAL aData, cJson, cContentType, aResp, aAuthorization, aRecipient := {}
Try
//oOle := CreateObject( 'MSXML2.XMLHTTP' )
oOle := Createobject("MSXML2.ServerXMLHTTP")
Catch
oOle := CreateObject( 'Microsoft.XMLHTTP' )
End
aData := hash()
AADD(aRecipient,'+393123456789')
aData["recipient"] = aRecipient
aData["message"] = "Ths is a Test"
aData["sender"] = "MarcoBoschi"
aData["message_type"] = "n"
aAuthorization := {{"user_key","9999999"},{"Access_token","TOKENALFANUMERICO"}}
cJson := hb_jsonEncode(aData,.f.)
cContentType:="application/json"
aResp := SendPostToUrl( "https://app.xxxxxxx.it/API/v1.0/REST/sms", cJson, cContentType, aAuthorization )
if valtype(aResp) == 'C'
MsgInfo(aResp)
Else
xbrowse(aResp) // Ver respuesta
endif
Return NIL
STATIC Function SendPostToUrl( cUrl, cParams,cContentType,aAuthorization )
Local cRet:='',uRet, i, oError
default cContentType:="application/json"
default aAuthorization:={}
oOle:Open( 'POST', cUrl, .f. )
if !empty(aAuthorization)
for i := 1 TO len(aAuthorization)
oOle:SetRequestHeader( aAuthorization[i,1],aAuthorization[i,2])
next i
endif
oOle:SetRequestHeader( "Content-Type",cContentType)
try
oOle:Send( cParams )
Catch oError
MsgInfo(oError:description)
return "Error"
end try
cRet:=""
IF !oOle:ResponseBody = NIL
hb_jsonDecode(oOle:ResponseBody,@cRet)
ELSE
cRet := oOle:ResponseText
ENDIF
Return cRet
- MarcoBoschi
- Posts: 1070
- Joined: Thu Nov 17, 2005 11:08 am
- Location: Padova - Italy
- Contact:
Re: Send sms POST
Excelente Marco!
Me alegro haya sido de utilidad!
Me alegro haya sido de utilidad!
- MarcoBoschi
- Posts: 1070
- Joined: Thu Nov 17, 2005 11:08 am
- Location: Padova - Italy
- Contact:
Re: Send sms POST
Marco Boschi
info@marcoboschi.it
info@marcoboschi.it