-
-
Save wqweto/8ccac82377baf5e6e362da27647cb029 to your computer and use it in GitHub Desktop.
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
'========================================================================= | |
' | |
' First add mdJson.bas module to your project from this address | |
' | |
' https://gist.github.com/wqweto/e92dce63a68cd3ff9ca91b053b9510c9 | |
' | |
' Then copy/paste follwing code into an empty form | |
' | |
' Change STR_URL and STR_APIKEY to match your API address and credentials | |
' | |
'========================================================================= | |
Option Explicit | |
Private Sub Form_Load() | |
Const STR_URL As String = "http://127.0.0.1:61345/" | |
Const STR_APIKEY As String = "123456" | |
Dim oJson As Object | |
Dim oMessage As Object | |
JsonValue(oMessage, "$.text") = "test msg 88" | |
JsonValue(oMessage, "$.numbers[-1]") = "966555528643" | |
JsonValue(oMessage, "$.numbers[-1]") = "966555528644" | |
JsonValue(oMessage, "$.numbers[-1]") = "966555528645" | |
JsonValue(oMessage, "$.number_iso") = "SA" | |
JsonValue(oMessage, "$.sender") = "" | |
JsonValue(oJson, "$.messages[-1]") = oMessage | |
' Debug.Print JsonDump(oJson) | |
Dim oResponse As Object | |
Dim sError As String | |
Set oResponse = JsonParseObject(pvPostJson(STR_URL, STR_APIKEY, JsonDump(oJson)), sError) | |
If oResponse Is Nothing Then | |
Debug.Print sError | |
End If | |
End Sub | |
Private Function pvPostJson(sUrl As String, sApiKey As String, sPostData As String) As String | |
Const HTTPREQUEST_SETCREDENTIALS_FOR_SERVER As Long = 0 | |
With CreateObject("WinHttp.WinHttpRequest.5.1") | |
.Open "POST", sUrl | |
.SetRequestHeader "Accept", "application/json" | |
.SetRequestHeader "Content-Type", "application/json" | |
.SetRequestHeader "User-Agent", "Etqan" | |
.SetCredentials sApiKey, vbNullString, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER | |
.Send sPostData | |
pvPostJson = .ResponseText | |
End With | |
End Function |
Mail me complete working code with complete working JSON request, real API service address and your real API secret in any language you already have (PHP, C#, whatever) and I'll send you back a working VB6 code for you to study.
You can find my e-mail address in my github profile or in header of shared code I have on the internet.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you dear
I did that but no succeed because I thank must me I put API Secret
you don't put API Secret in the code
must me I put url , Api key and Api secret