34 lines
928 B
Plaintext
34 lines
928 B
Plaintext
#include once "windows.bi"
|
|
#include once "win/wininet.bi"
|
|
|
|
' Create InternetOpen and InternetConnect objects
|
|
Dim As HINTERNET hInternet, hConnect, hRequest
|
|
Dim As String dato
|
|
Dim As Byte buffer(4096)
|
|
Dim As DWORD dwRead
|
|
|
|
' Initialize Internet connection
|
|
hInternet = InternetOpen("FreeBASIC", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0)
|
|
hConnect = InternetConnect(hInternet, "www.example.com", INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0)
|
|
|
|
' Open request
|
|
hRequest = HttpOpenRequest(hConnect, "GET", "/index.html", NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0)
|
|
|
|
' Send request
|
|
HttpSendRequest(hRequest, NULL, 0, NULL, 0)
|
|
|
|
' Read response
|
|
While InternetReadFile(hRequest, @buffer(0), Sizeof(buffer), @dwRead) And dwRead > 0
|
|
dato &= *Cast(zstring Ptr, @buffer(0))
|
|
Wend
|
|
|
|
' Print response
|
|
Print dato
|
|
|
|
' Clean up
|
|
InternetCloseHandle(hRequest)
|
|
InternetCloseHandle(hConnect)
|
|
InternetCloseHandle(hInternet)
|
|
|
|
Sleep
|