Skip to content
Accueil » API SMS Octopush » Code source API SMS WINDEV

Code source API SMS WINDEV

Fichier Main

cOctoPush is a Class
PRIVATE
_user_loginis string
_api_keyis string
_sms_tex is string
_sms_senderis string
_sms_typeis string
_sending_dateis string
_sms_modeis int
_sms_recipientsis string
_transactionalis boolean
_with_repliesis boolean
_url_simpleis string
_url_difereis string
_url_tranactionalis string
_url_withrepliesis string
END
PROCEDURE Constructor()
url_simple = « https://www.octopush-dm.com/api/sms/json?user_login=%1&api_key=%2&sms_recipients=%3&sms_text=%4&sms_type=%5&sms_sender=%6 »
url_difere = « https://www.octopush-dm.com/api/sms/json?user_login=%1&api_key=%2&sms_recipients=%3&sms_text=%4&sms_type=%5&sms_sender=%6&sms_mode=%7&sending_date=%8 »
url_tranactional = « https://www.octopush-dm.com/api/sms/json?user_login=%1&api_key=%2&sms_recipients=%3&sms_text=%4&sms_type=%5&sms_sender=%6&transactional=1 »
url_withreplies = « https://www.octopush-dm.com/api/sms/json?user_login=%1&api_key=%2&sms_recipients=%3&sms_text=%4&sms_type=%5&sms_sender=%6&with_replies=1 »
PROCEDURE Destructor()
PROCEDURE PRIVATE api_key() : string
RESULT _api_key
PROCEDURE PRIVATE api_key(Value is string)
_api_key=Value
PROCEDURE PRIVATE user_login() : string
RESULT _user_login
PROCEDURE PRIVATE user_login(Value is string)
_user_login=Value
PROCEDURE PRIVATE sms_text() : string
RESULT Gauche(_sms_text,459)
PROCEDURE PRIVATE sms_text(Value is string)
_sms_text=Value
PROCEDURE PRIVATE sms_sender() : string
RESULT _sms_sender
PROCEDURE PRIVATE sms_sender(Value is string)
_sms_sender=Value
PROCEDURE PRIVATE sms_type() : string
RESULT _sms_type
PROCEDURE PRIVATE sms_type(Value is string)
_sms_type=Value
PROCEDURE PRIVATE sending_date() : DateTime
RESULT _sending_date
PROCEDURE PRIVATE sending_date(Value is DateTime)
_sending_date=Value
PROCEDURE PRIVATE sms_mode() : int
RESULT _sms_mode
PROCEDURE PRIVATE sms_mode(Value is int)
_sms_mode=Value
PROCEDURE PRIVATE sms_recipients() : string
RESULT _sms_recipients
PROCEDURE PRIVATE sms_recipients(Value is string)
_sms_recipients=Value
PROCEDURE PRIVATE transactional() : boolean
RESULT _transactional
PROCEDURE PRIVATE transactional(Value is boolean)
_transactional=Value
PROCEDURE PRIVATE with_replies() : boolean
RESULT _with_replies
PROCEDURE PRIVATE with_replies(Value is boolean)
_with_replies=Value
PROCEDURE PRIVATE url_simple() : string
RESULT _url_simple
PROCEDURE PRIVATE url_simple(Value is string)
_url_simple=Value
PROCEDURE PRIVATE url_tranactional() : string
RESULT _url_tranactional
PROCEDURE PRIVATE url_tranactional(Value is string)
_url_tranactional=Value
PROCEDURE PRIVATE url_difere() : string
RESULT _url_difere
PROCEDURE PRIVATE url_difere(Value is string)
_url_difere=Value
PROCEDURE PRIVATE url_withreplies() : string
RESULT _url_withreplies
PROCEDURE PRIVATE url_withreplies(Value is string)
_url_withreplies=Value
// Summary: Mandatory verification
PROCEDURE PRIVATE sms_recipients_convert(psms_recipients is string):string
smsRecipients is string
smsRecipients = psms_recipients
//controle parametre obligatoire
smsRecipients=Remplace(smsRecipients, » « ,«  »)
smsRecipients=Remplace(smsRecipients,« / »,«  »)
smsRecipients=Remplace(smsRecipients,« -« ,«  »)
smsRecipients=Remplace(smsRecipients,« . »,«  »)
RESULT smsRecipients
// Summary: add +
PROCEDURE PRIVATE sms_text_convert(psms_text is string):string
sSMSText_Convert is string = psms_text
//SMS Text
sSMSText_Convert = Replace(sSMSText_Convert, » « ,« + »)
RESULT sSMSText_Convert
//Il s’agit de l’envoi simple de SMS. Vous pouvez spécifier plusieurs numéro de téléphone dans le paramètre « sms_recipients » en les séparant par une « , ».
PROCEDURE PUBLIC Octopush_send_Simple(puser_login is string=«  », pAPI_Key is string=«  », psms_text is string=«  », psms_recipients is string=«  », psms_type is string=«  », psms_sender is string=«  »)
sCodeTestParam is string
sURLTOSend >is string
//Affectation
user_login = puser_login
api_key = pAPI_Key
sms_text = sms_text_convert(psms_text)
sms_sender = psms_sender
sms_type = psms_type
sms_recipients = sms_recipients_convert(psms_recipients)
//Verification valid data
sCodeTestParam = test_parameters()
IF sCodeTestParam <> « 000 » THEN
RESULT sCodeTestParam
END
//Build the URL
sURLTOSend = StringBuild(url_simple,:user_login,:api_key, :sms_recipients, :sms_text, :sms_type, :sms_sender)
RESULT Octopush_api_call(sURLTOSend)
// Summary: Verification of the parameters
PROCEDURE PRIVATE test_parameters() : string
////////////////////////////////////
//Validation mandatory parameters
IF :user_login = «  » THEN
RESULT « 108 »
END
IF :api_key = «  » THEN
RESULT « 101 »
END
IF :sms_text = «  » THEN
RESULT « 107 »
END
IF :sms_type=«  » THEN
RESULT « 208 »
END
IF :sms_sender = «  » THEN
RESULT « 106 »
END
IF :sms_recipients = «  » THEN
RESULT « 103 »
END
RESULT « 000 »
// Summary: CALL the API and result the content JSON format
PROCEDURE PRIVATE Octopush_api_call(pURLToSend is string)
IF pURLToSend = «  » THEN
RESULT «  »
END
oRequest is httpRequest
oResponse is httpResponse
oRequest..URL = pURLToSend
oRequest..Method = httpGet
// Runs the request and retrieves the response
oResponse = HTTPSend(oRequest)
IF ErrorOccurred THEN
RESULT « System error sending HTTP request. »
END
RESULT oResponse..Content
// Summary: //Tout envoi via l’API SMS Octopush peut être planifié dans le temps.
//Dès que la date que vous avez spécifiée est dépassée, nous faisons partir vos SMS.
//La date attendue doit être présentée sous la forme d’un timestamp, au format GMT+1.
PROCEDURE Octopush_send_differe(puser_login is string=«  », pAPI_Key is string=«  », psms_text is string=«  », psms_recipients is string=«  », psms_type is string=«  », psms_sender is string=«  », psms_mode is int=1, psms_sending_date is string=«  »)
sCodeTestParam is string
sURLTOSend >is string
//Affectation
user_login = puser_login
api_key = pAPI_Key
sms_text = sms_text_convert(psms_text)
sms_sender = psms_sender
sms_type = psms_type
sms_recipients = sms_recipients_convert(psms_recipients)
sending_date >= psms_sending_date
sms_mode = psms_mode
//Verification valid data
sCodeTestParam = test_parameters()
IF sCodeTestParam <> « 000 » THEN
RESULT sCodeTestParam
END
//Build the URL
sURLTOSend = StringBuild(url_difere,:user_login,:api_key, :sms_recipients, :sms_text, :sms_type, :sms_sender, :sms_mode, :sending_date)
RESULT Octopush_api_call(sURLTOSend)
// Summary:
//Cette option est dédiée aux envois NON COMMERCIAUX.
//Exemples : confirmations d’inscriptions, de paiement, d’expédition de commande. Envoi d’alertes, de rappels de rendez-vous, etc…
//Avec cette option, vous pouvez donc envoyer vos SMS 24h/24, et 7j/7.
//
// ATTENTION : Toute erreur, toute fraude constatée par l’envoi de publicité avec l’option « SMS transactionnel » est passible d’une amende décrite dans conditions générales.
// Nous vous prions d’utiliser cette option avec précaution et en connaissance de cause.
PROCEDURE Octopush_send_transactionel(puser_login is string=«  », pAPI_Key is string=«  », psms_text is string=«  », psms_recipients is string=«  », psms_type is string=«  », psms_sender is string=«  »)
sCodeTestParam is string
sURLTOSend is string
//Affectation
user_login = puser_login
api_key = pAPI_Key
sms_text = sms_text_convert(psms_text)
sms_sender = psms_sender
sms_type = psms_type
sms_recipients = sms_recipients_convert(psms_recipients)
//Verification valid data
sCodeTestParam = test_parameters()
IF sCodeTestParam <> « 000 » THEN
RESULT sCodeTestParam
END
//Build the URL
sURLTOSend = StringBuild(url_tranactional,:user_login,:api_key, :sms_recipients, :sms_text, :sms_type, :sms_sender)
RESULT Octopush_api_call(sURLTOSend)
// Summary: Cette option est dédiée aux envois NON COMMERCIAUX.
//Exemples : confirmations d’inscriptions, de paiement, d’expédition de commande. Envoi d’alertes, de rappels de rendez-vous, etc…
//Avec cette option, vous pouvez donc envoyer vos SMS 24h/24, et 7j/7. dicate an example.
////
PROCEDURE Octopush_send_reponse(puser_login is string=«  », pAPI_Key is string=«  », psms_text is string=«  », psms_recipients is string=«  », psms_type is string=«  », psms_sender is string=«  »)
sCodeTestParam is string
sURLTOSend is string
//Affectation
user_login = puser_login
api_key = pAPI_Key
sms_text = sms_text_convert(psms_text)
sms_sender = psms_sender
sms_type = psms_type
sms_recipients = sms_recipients_convert(psms_recipients)
//Verification valid data
sCodeTestParam = test_parameters()
IF sCodeTestParam <> « 000 » THEN
RESULT sCodeTestParam
END
//Build the URL
sURLTOSend = StringBuild(url_withreplies,:user_login,:api_key, :sms_recipients, :sms_text, :sms_type, :sms_sender)
RESULT Octopush_api_call(sURLTOSend)
// Summary: /
//Cette option vous permet de personnaliser vos SMS pour chacun de vos destinataires.
//Vous pouvez faire cette personnalisation de votre côté, mais cela vous oblige à nous transmettre autant de requêtes qu’il y a de numéros de téléphones, ce qui peut prendre plusieurs minutes selon la taille de vos listes.
//Grâce à l’option de publipostage de Octopush, votre envoi ne durera que quelques secondes pour l’ensemble de vos contacts.
PROCEDURE Octopush_send_publipostage(puser_login is string= » », pAPI_Key is string= » », psms_text is string= » », psms_recipients is string= » », psms_sender is string= » », precipients_first_names is string= » »,precipients_last_names is string = «  », psms_fields_1 is string = » », psms_fields_2 is string = » », psms_fields_3 is string = » »)
sCodeTestParam is string
sURLTOSend is string
//special case URL
sURLTOSend = « https://www.octopush-dm.com/api/sms/?user_login=%1&api_key=%2&sms_text=%3&sms_recipients=%4 »
//Affectation
user_login = puser_login
api_key = pAPI_Key
sms_text = sms_text_convert(psms_text)
sms_sender = psms_sender
sms_recipients = sms_recipients_convert(psms_recipients)
//Verification valid data
sCodeTestParam = test_parameters()
IF sCodeTestParam <> « 000 » THEN
RESULT sCodeTestParam
END
IF precipients_first_names <> «  » THEN
sURLTOSend+=« &recipients_first_names »+precipients_first_names
END
IF precipients_last_names <> «  » THEN
sURLTOSend+=« &recipients_last_names »+precipients_last_names
END
IF psms_fields_1 <> «  » THEN
sURLTOSend+=« &sms_fields_1 »+psms_fields_1
END
IF psms_fields_2 <> «  » THEN
sURLTOSend+=« &sms_fields_2 »+psms_fields_2
END
IF psms_fields_3 <> «  » THEN
sURLTOSend+=« &sms_fields_3 »+psms_fields_3
END
sURLTOSend+=« &sms_type=WWW&sms_sender=Octopush&sms_mode=2 »
//Build the URL
sURLTOSend = StringBuild(url_tranactional,:user_login,:api_key, :sms_recipients, :sms_text, :sms_type, :sms_sender)
RESULT Octopush_api_call(sURLTOSend)

Objet Principal