'send a http request vb6 button click event

By clicking on a command button i want to send a http request to turn on a light (Mqtt rest api) but don't want to open any web browser on the process.

it's kind of get request send.

i have tried out (as i'm using vb6 to do that) Shell "explorer http://blynk-cloud.com/e_6ZCMSsELAVwQH_ZvblxKY3I0CmmBDL/update/D12?value=1"

(but the urls open with browser =). i even don't want to open the browser either.

please suggest me something which fulfills my goal



Solution 1:[1]

Not sure if you wanted an example or if you got enough info from the comments above??

This is a simple example that uses your url and demoes getting the results back. You can add headers if required, but you didn't mention that - and you didn't want to use POST.

Public Sub SendHTTPRequest()

    Dim request As Object
    
    Set request = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    
    request.Open "GET", "http://blynk-cloud.com/e_6ZCMSsELAVwQH_ZvblxKY3I0CmmBDL/update/D12?value=1", False    'populates object fields
    request.send
    Debug.Print request.responseText
    
    Set request = Nothing    

End Sub

Solution 2:[2]

Public Sub SendHTTPRequest()

Set Req = New WinHttp.WinHttpRequest
  With Req
   .open "GET", "http://blynk-cloud.com/e_6ZCMSsELAVwQH_ZvblxKY3I0CmmBDL/update/D12?value=1", False
   .send
  End With
Debug.Print Req.responseText
Set Req = Nothing  
End Sub
       
    

I used WinHttpRequest. Adding the reference to "Microsoft WinHTTP Services, version 5.1"

And now it works.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dbmitch
Solution 2 BranchDev