Skip to content

Instantly share code, notes, and snippets.

@byjg
Created July 10, 2018 23:35
Show Gist options
  • Save byjg/65f3899c842d3352c678f006a5109645 to your computer and use it in GitHub Desktop.
Save byjg/65f3899c842d3352c678f006a5109645 to your computer and use it in GitHub Desktop.
Sub SMS()
Dim Result As String
Result = EnviarSMS("21", "999999999", "Mensagem", "Usuario", "Senha")
MsgBox Result
End Sub
Function RequestURL(Method As String, Dict As Variant) As String
Dim QueryString As String
Dim Key As Variant
For Each Key In Dict.Keys
QueryString = QueryString & Key & "=" & Dict(Key) & "&"
Next Key
Set req = CreateObject("WinHttp.WinHttpRequest.5.1")
req.Open "GET", "http://www.byjg.com.br/ws/sms?httpmethod=" & Method & "&" & QueryString
req.Send
RequestURL = req.ResponseText
End Function
Function EnviarSMS(Ddd As String, Celular As String, Mensagem As String, Usuario As String, Senha As String)
Set Dict = CreateObject("scripting.Dictionary")
With Dict
.Add Key:="ddd", Item:=Ddd
.Add Key:="celular", Item:=Celular
.Add Key:="mensagem", Item:=Mensagem
.Add Key:="usuario", Item:=Usuario
.Add Key:="senha", Item:=Senha
End With
EnviarSMS = RequestURL("enviarsms", Dict)
' Result pode ser
' OK|mensagem
' ERR|mensagem
End Function
Function Creditos(Usuario As String, Senha As String)
Set Dict = CreateObject("scripting.Dictionary")
Dict.Add Key:="usuario", Item:=Usuario
Dict.Add Key:="senha", Item:=Senha
Creditos = RequestURL("creditos", Dict)
' Result pode ser
' OK|400, Usuário ou senha inválidos
' OK|ARRAY|1|100,2020/09/08
' OK|ARRAY|2|100,2020/09/08|58,2013/08/30
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment