Windev SMS API example

Version française


//Construction du payload
vSms est un Variant
vMessage est un Variant
vMessage.sender = "Asterix"
vMessage.text = "Message via Api"
vMessage.pushtype = "alert"
vSms.message = vMessage
tabNumbers est un tableau de chaînes = ["0600000000", "0600000001"]
tabGsm est un tableau de Variants

POUR TOUT sNumber DE tabNumbers
	vGsm est un Variant
	vGsm.value = sNumber
	tabGsm.Ajoute(vGsm)
FIN

vRecipient est un Variant
vRecipient.gsm = tabGsm
vSms.recipients = vRecipient
vPostData est un Variant
vPostData.sms = vSms

//Requete
sRequestUrl est une chaîne = "https://api.smsup.ch/send"
sToken est une chaîne = "" //Votre token cree dans la plateforme https://app.smsup.ch/developers/api-tokens
sHeader est une chaîne
sHeader = "Accept: application/json" + RC + "Authorization: Bearer " + sToken

SI HTTPRequête(sRequestUrl,"Windev", sHeader,VariantVersJSON(vPostData), "application/json") = Vrai ALORS
	Trace("requete OK, resultat :", HTMLVersTexte(HTTPDonneRésultat()))	//Imprime le resultat de notre API
SINON
	Erreur(ErreurInfo())
FIN	
  	
	

English version


//Create a Payload
vSms is Variant
vMessage is Variant
vMessage.sender = "Asterix"
vMessage.text = "Message via Api"
vMessage.pushtype = "alert"
vSms.message = vMessage
tabNumbers is array of strings = ["0600000000", "0600000001"]
tabGsm is array of Variants

FOR EACH sNumber OF tabNumbers
	vGsm is Variant
	vGsm.value = sNumber
	tabGsm.Add(vGsm)
END

vRecipient is Variant
vRecipient.gsm = tabGsm
vSms.recipients = vRecipient
vPostData is Variant
vPostData.sms = vSms

//Request
sRequestUrl is string = "https://api.smsup.ch/send"
sToken is string = "" //Your token created in your platform's profile https://app.smsup.ch/developers/api-tokens
sHeader is string
sHeader = "Accept: application/json" + CR + "Authorization: Bearer " + sToken

IF HTTPRequest(sRequestUrl,"Windev", sHeader,VariantToJSON(vPostData), "application/json") = True THEN
	Trace("requete OK, resultat :", HTMLToText(HTTPGetResult()))	//API return value
ELSE
	Error(ErrorInfo())
END