Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Const
Const
Const
Const
Const
i As Integer
acode As Integer
chr As String
hexValue As String
finalString As String
finalString = ""
For i = 1 To Len(Text) Step 1
acode = Asc(Mid$(Text, i, 1))
Select Case acode
Case 48 To 57, 65 To 90, 97 To 122
' don't touch alphanumeric chars
finalString = finalString & Mid$(Text, i, 1)
Case 32
' replace space with "+"
'Mid$(Text, i, 1) = "+"
finalString = finalString & "+"
Case Else
hexValue = Hex$(acode)
Select Case Len(hexValue)
Case 1
hexValue = "0" & hexValue
Case 2
'ok
Case Else
'carattere non valido
'skip
hexValue = ""
End Select
' replace punctuation chars with "%hex"
finalString = finalString & "%" & hexValue
End Select
Next
Return finalString
End Function
Function skebbyGatewaySendSMS(username As String, password As String, recipients
() As String, Text As String, sms_type As String, Optional sender_number As Stri
ng = "", Optional sender_string As String = "", Optional user_reference As Strin
g = "", Optional charset As String = "") As String
Dim sender_error, url, method, parameters, msg As String
Dim xmlhttp As Object
xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
url = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php"
sender_error = "Puoi specificare solo un tipo di mittente, numerico o al
fanumerico"
method = "send_sms_classic"
Select Case sms_type
Case SMS_TYPE_CLASSIC
method = "send_sms_classic"
Case SMS_TYPE_CLASSIC_PLUS
method = "send_sms_classic_report"
Case SMS_TYPE_BASIC
method = "send_sms_basic"
Case SMS_TYPE_TEST_CLASSIC
method = "test_send_sms_classic"
Case SMS_TYPE_TEST_CLASSIC_PLUS
method = "test_send_sms_classic_report"
Case SMS_TYPE_TEST_BASIC
method = "test_send_sms_basic"
Case Else
method = "send_sms_classic"
End Select
parameters = "method=" & method & "&" _
& "username=" & URLEncode(username) & "&" _
& "password=" & URLEncode(password) & "&" _
& "text=" & URLEncode(Text) & "&" _
& "recipients[]=" & Join(recipients, "&recipien
ts[]=")
If sender_number <> "" And sender_string <> "" Then
skebbyGatewaySendSMS = "status=failed&message=" & sender_error
Exit Function
End If
If sender_number <> "" Then parameters = parameters & "&sender_number="
& URLEncode(sender_number)
If sender_string <> "" Then parameters = parameters & "&sender_string="
& URLEncode(sender_string)
If user_reference <> "" Then parameters = parameters & "&user_reference=
" & URLEncode(user_reference)
Select Case charset
Case "UTF-8"
parameters = parameters & "&charset=UTF-8"
Case Else
End Select
End If
' -----------------------------------------------------------------' Controlla la documentazione completa all'indirizzo http:#www.skebby.it
/business/index/send-docs/
' -----------------------------------------------------------------' Per i possibili errori si veda http:#www.skebby.it/business/index/send
-docs/#errorCodesSection
' ATTENZIONE: in caso di errore Non si deve riprovare l'invio, trattando
si di errori bloccanti
' -----------------------------------------------------------------msg = xmlhttp.responseText
xmlhttp = Nothing
skebbyGatewaySendSMS = msg
End Function
Function skebbyGatewayGetCredit(username As String, password As String, Optional
charset As String = "") As String
Dim url, method, parameters, msg As String
Dim xmlhttp As Object
xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
url = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php"
method = "get_credit"
parameters = "method=" & method & "&" _
& "username=" & URLEncode(username) & "&" _
& "password=" & URLEncode(password)
Select Case charset
Case "UTF-8"
parameters = parameters & "&charset=UTF-8"
Case Else
End Select
'
'
'
I SKEBBY
'
' ------------- Testing invio SMS Classic--------' TEST di invio SMS CLASSIC con mittente personalizzato di tipo alfanume
rico
' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mik
e, how are you?", SMS_TYPE_TEST_CLASSIC,"","John")
' TEST di invio SMS CLASSIC con mittente personalizzato di tipo numerico
' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mik
e, how are you?", SMS_TYPE_TEST_CLASSIC,"393471234567")
' ------------- Testing invio SMS Classic Plus--------' TEST di invio SMS CLASSIC PLUS(con notifica) con mittente personalizza
to di tipo alfanumerico
' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mik
e, how are you?", SMS_TYPE_TEST_CLASSIC_PLUS,"","John")
' TEST di invio SMS CLASSIC PLUS(con notifica) con mittente personalizza
to di tipo numerico
' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mik
e, how are you?", SMS_TYPE_TEST_CLASSIC_PLUS,"393471234567")
' ------------- Testing invio SMS Basic--------------' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mik
e, how are you? By John", SMS_TYPE_TEST_BASIC)
'
'
'
I SKEBBY
'
' ------------ Controllo del CREDITO RESIDUO ------------' result = skebbyGatewayGetCredit("username", "password")
Dim responses As String()
responses = Split(result, "&")
Dim Response As String = ""
For Each Item In responses
Response = Response & Item & vbCrLf
Next
MsgBox(Response, vbOKOnly + vbInformation, "Result")
End Sub