Last active
January 3, 2018 14:14
-
-
Save expressmailing/84e9e7cbe09e4d4f087c21358b964400 to your computer and use it in GitHub Desktop.
Exemple en VB 4/5/6 d'envoi de SMS unitaire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub Form_Load() | |
' Création du XML à poster | |
Dim xml As String | |
xml = "<request login=""your-login"" password=""your-password"">" & _ | |
"<push media=""sms"" type=""on_demand"" name=""Test API Sms VB6"">" & _ | |
"<message type=""text"">Mon premier test sms</message>" & _ | |
"<recipients>" & _ | |
"<add target=""+33 600000000"" />" & _ | |
"</recipients>" & _ | |
"</push>" & _ | |
"</request>" | |
' Construction et envoi de la requête HTTP | |
Dim postURL As String | |
postURL = "http://api.express-mailing.com/transac/api.ashx" | |
With CreateObject("MSXML2.XMLHTTP") | |
.open "POST", postURL, False | |
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" | |
.send (xml) | |
response = .responseText | |
End With | |
MsgBox (response) | |
End Sub | |
Private Function EncodeBase64(ByRef binary() As Byte) As String | |
Dim objXML, objNode | |
Set objXML = CreateObject("Microsoft.XMLDOM") | |
Set objNode = objXML.createElement("doc") | |
objNode.dataType = "bin.base64" | |
objNode.nodeTypedValue = binary | |
EncodeBase64 = objNode.Text | |
Set objNode = Nothing | |
Set objXML = Nothing | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment