d_p_ruul
asked on
Internet Transfer Control Problem
hello i hope someone can help me here, i am using the Internet Transfer Control to post data to a web page and then retrieve the results from that page but when i call the execute command i get the error >
runtime error '35756'
unable to complete request
what does that mean and why does it do that?
or is there another way i can post data to as web page that replys with the query result
runtime error '35756'
unable to complete request
what does that mean and why does it do that?
or is there another way i can post data to as web page that replys with the query result
Can you show us your code?
Daniel,
he's using the control. The code you posted is for using the dll (no control).
I've got a working application that does uploads using the internet transfer control. Maybe I could help if I knew where the error occured? (I ran into a bunch of them making my app)
he's using the control. The code you posted is for using the dll (no control).
I've got a working application that does uploads using the internet transfer control. Maybe I could help if I knew where the error occured? (I ran into a bunch of them making my app)
My code is after
-------------------------- ---------- ---------- ----
Here the Get example :
--------------------------
Here the Get example :
Daniel,
he's using the control. The code you posted is for using the dll (no control).
I've got a working application that does uploads using the internet transfer control. Maybe I could help if I knew where the error occured? (I ran into a bunch of them making my app)
he's using the control. The code you posted is for using the dll (no control).
I've got a working application that does uploads using the internet transfer control. Maybe I could help if I knew where the error occured? (I ran into a bunch of them making my app)
sorry about the dupe post..
Daniel, my comment about showing the code was meant for d_p_ruul
ASKER
here is the code i use
PData = "xid=" & Xid.Xid & "&submit=submit"
strURL = Site + "StateSelect.php"
inetState.URL = strURL + strFormData
inetState.Execute , "POST", PData, "Content-Type: _ application/x-www-form-url encoded"
all it does is set the post data and then execute.
this problem used to come up after a few week of programming normally this code works but after a while the "error '35756'
unable to complete request" comes up nothing using the internet transfer control works?????????????
PData = "xid=" & Xid.Xid & "&submit=submit"
strURL = Site + "StateSelect.php"
inetState.URL = strURL + strFormData
inetState.Execute , "POST", PData, "Content-Type: _ application/x-www-form-url
all it does is set the post data and then execute.
this problem used to come up after a few week of programming normally this code works but after a while the "error '35756'
unable to complete request" comes up nothing using the internet transfer control works?????????????
What are you expecting it to do? Posting is usually where you submit some form data to a script or page to process.
If you are waiting for a response, then you probably need to have a loop after this Exectute statement that says something like:
While inetState.StillExecuting
DoEvents
Wend
Now, you might be able to do something with the return value.
The inet control can be limited. I use a sample class that I downloaded from Microsoft which makes calls to the WININET API. The control is a little simpler, but the API seems to work a little better.
If you are waiting for a response, then you probably need to have a loop after this Exectute statement that says something like:
While inetState.StillExecuting
DoEvents
Wend
Now, you might be able to do something with the return value.
The inet control can be limited. I use a sample class that I downloaded from Microsoft which makes calls to the WININET API. The control is a little simpler, but the API seems to work a little better.
ASKER
thanx mdougan i did a search for "WININET API" at microsoft and found a good example of how to POST some variables to, and retrieve the HTML from a script.
that code is good but i have used the Internet Transfer Control for all my code and would have to rewrite heaps.
has anyone ever got a :
"error '35756'unable to complete request"
that code is good but i have used the Internet Transfer Control for all my code and would have to rewrite heaps.
has anyone ever got a :
"error '35756'unable to complete request"
Hi d_p_ruul,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Refund points and save as a 0-pt PAQ.
d_p_ruul, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit. Explain why.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Refund points and save as a 0-pt PAQ.
d_p_ruul, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit. Explain why.
==========
DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here, the wininet.bas file :
' --------------------------
'
' WININET.TXT -- WININET API Declarations for Visual Basic
'
' Copyright (C) 1998 Microsoft Corporation
'
' This file is required for the Visual Basic 6.0 version of the APILoader.
' This file is backwards compatible with previous releases
' of the APILoader with the exception that public constants are no longer declared
' as Global or Public in this file.
'
' This file contains only the public const, Type,
' and Declare statements for the WININET APIs.
'
' You have a royalty-free right to use, modify, reproduce and distribute
' this file (and/or any modified version) in any way you find useful,
' provided that you agree that Microsoft has no warranty, obligation or
' liability for its contents. Refer to the Microsoft Windows Programmer's
' Reference for further information.
'
' --------------------------
Public Const MAX_PATH = 260
Public Const NO_ERROR = 0
Public Const FILE_ATTRIBUTE_READONLY = &H1
Public Const FILE_ATTRIBUTE_HIDDEN = &H2
Public Const FILE_ATTRIBUTE_SYSTEM = &H4
Public Const FILE_ATTRIBUTE_DIRECTORY = &H10
Public Const FILE_ATTRIBUTE_ARCHIVE = &H20
Public Const FILE_ATTRIBUTE_NORMAL = &H80
Public Const FILE_ATTRIBUTE_TEMPORARY = &H100
Public Const FILE_ATTRIBUTE_COMPRESSED = &H800
Public Const FILE_ATTRIBUTE_OFFLINE = &H1000
Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Public Const ERROR_NO_MORE_FILES = 18
Declare Function InternetFindNextFile Lib "wininet.dll" Alias "InternetFindNextFileA" (ByVal hFind As Long, lpvFindData As WIN32_FIND_DATA) As Long
Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" (ByVal hFtpSession As Long, ByVal lpszSearchFile As String, lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal dwContent As Long) As Long
Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hFtpSession As Long, ByVal lpszLocalFile As String, ByVal lpszRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String, ByRef lpdwCurrentDirectory As Long) As Boolean
' Initializes an application's use of the Win32 Internet functions
Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
' User agent public constant.
Public Const scUserAgent = "vb wininet"
' Use registry access settings.
Public Const INTERNET_OPEN_TYPE_PRECONF
Public Const INTERNET_OPEN_TYPE_DIRECT = 1
Public Const INTERNET_OPEN_TYPE_PROXY = 3
Public Const INTERNET_INVALID_PORT_NUMB
Public Const FTP_TRANSFER_TYPE_ASCII = &H1
Public Const FTP_TRANSFER_TYPE_BINARY = &H2
' Opens a HTTP session for a given site.
Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Declare Function InternetGetLastResponseInf
' Number of the TCP/IP port on the server to connect to.
Public Const INTERNET_DEFAULT_FTP_PORT = 21
Public Const INTERNET_DEFAULT_GOPHER_PO
Public Const INTERNET_DEFAULT_HTTP_PORT
Public Const INTERNET_DEFAULT_HTTPS_POR
Public Const INTERNET_DEFAULT_SOCKS_POR
Public Const INTERNET_OPTION_CONNECT_TI
Public Const INTERNET_OPTION_RECEIVE_TI
Public Const INTERNET_OPTION_SEND_TIMEO
Public Const INTERNET_OPTION_USERNAME = 28
Public Const INTERNET_OPTION_PASSWORD = 29
Public Const INTERNET_OPTION_PROXY_USER
Public Const INTERNET_OPTION_PROXY_PASS
' Type of service to access.
Public Const INTERNET_SERVICE_FTP = 1
Public Const INTERNET_SERVICE_GOPHER = 2
Public Const INTERNET_SERVICE_HTTP = 3
' Opens an HTTP request handle.
Declare Function HttpOpenRequest Lib "wininet.dll" Alias "HttpOpenRequestA" (ByVal hHttpSession As Long, ByVal sVerb As String, ByVal sObjectName As String, ByVal sVersion As String, ByVal sReferer As String, ByVal something As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Public Const GENERIC_READ = &H80000000
Public Const GENERIC_WRITE = &H40000000
' Sends the specified request to the HTTP server.
Declare Function HttpSendRequest Lib "wininet.dll" Alias "HttpSendRequestA" (ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal sOptional As String, ByVal lOptionalLength As Long) As Integer
' Queries for information about an HTTP request.
Declare Function HttpQueryInfo Lib "wininet.dll" Alias "HttpQueryInfoA" (ByVal hHttpRequest As Long, ByVal lInfoLevel As Long, ByRef sBuffer As Any, ByRef lBufferLength As Long, ByRef lIndex As Long) As Integer
' InternetErrorDlg
Declare Function InternetErrorDlg Lib "wininet.dll" (ByVal hWnd As Long, ByVal hInternet As Long, ByVal dwError As Long, ByVal dwFlags As Long, ByVal lppvData As Long) As Long
' InternetErrorDlg public constants
Public Const FLAGS_ERROR_UI_FILTER_FOR_
Public Const FLAGS_ERROR_UI_FLAGS_CHANG
Public Const FLAGS_ERROR_UI_FLAGS_GENER
Public Const FLAGS_ERROR_UI_FLAGS_NO_UI
Public Const FLAGS_ERROR_UI_SERIALIZE_D
Declare Function GetDesktopWindow Lib "user32.dll" () As Long
' The possible values for the lInfoLevel parameter include:
Public Const HTTP_QUERY_CONTENT_TYPE = 1
Public Const HTTP_QUERY_CONTENT_LENGTH = 5
Public Const HTTP_QUERY_EXPIRES = 10
Public Const HTTP_QUERY_LAST_MODIFIED = 11
Public Const HTTP_QUERY_PRAGMA = 17
Public Const HTTP_QUERY_VERSION = 18
Public Const HTTP_QUERY_STATUS_CODE = 19
Public Const HTTP_QUERY_STATUS_TEXT = 20
Public Const HTTP_QUERY_RAW_HEADERS = 21
Public Const HTTP_QUERY_RAW_HEADERS_CRL
Public Const HTTP_QUERY_FORWARDED = 30
Public Const HTTP_QUERY_SERVER = 37
Public Const HTTP_QUERY_USER_AGENT = 39
Public Const HTTP_QUERY_SET_COOKIE = 43
Public Const HTTP_QUERY_REQUEST_METHOD = 45
Public Const HTTP_STATUS_DENIED = 401
Public Const HTTP_STATUS_PROXY_AUTH_REQ
' Add this flag to the about flags to get request header.
Public Const HTTP_QUERY_FLAG_REQUEST_HE
Public Const HTTP_QUERY_FLAG_NUMBER = &H20000000
' Reads data from a handle opened by the HttpOpenRequest function.
Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Type INTERNET_BUFFERS
dwStructSize As Long ' used for API versioning. Set to sizeof(INTERNET_BUFFERS)
Next As Long ' INTERNET_BUFFERS chain of buffers
lpcszHeader As Long ' pointer to headers (may be NULL)
dwHeadersLength As Long ' length of headers if not NULL
dwHeadersTotal As Long ' size of headers if not enough buffer
lpvBuffer As Long ' pointer to data buffer (may be NULL)
dwBufferLength As Long ' length of data buffer if not NULL
dwBufferTotal As Long ' total size of chunk, or content-length if not chunked
dwOffsetLow As Long ' used for read-ranges (only used in HttpSendRequest2)
dwOffsetHigh As Long
End Type
Declare Function HttpSendRequestEx Lib "wininet.dll" Alias "HttpSendRequestExA" (ByVal hHttpRequest As Long, lpBuffersIn As INTERNET_BUFFERS, ByVal lpBuffersOut As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Declare Function HttpEndRequest Lib "wininet.dll" Alias "HttpEndRequestA" (ByVal hHttpRequest As Long, ByVal lpBuffersOut As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Declare Function InternetWriteFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumberOfBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Declare Function FtpOpenFile Lib "wininet.dll" Alias "FtpOpenFileA" (ByVal hFtpSession As Long, ByVal sFileName As String, ByVal lAccess As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Declare Function FtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, ByVal lpszFileName As String) As Boolean
Declare Function InternetSetOption Lib "wininet.dll" Alias "InternetSetOptionA" (ByVal hInternet As Long, ByVal lOption As Long, ByRef sBuffer As Any, ByVal lBufferLength As Long) As Integer
Declare Function InternetSetOptionStr Lib "wininet.dll" Alias "InternetSetOptionA" (ByVal hInternet As Long, ByVal lOption As Long, ByVal sBuffer As String, ByVal lBufferLength As Long) As Integer
' Closes a single Internet handle or a subtree of Internet handles.
Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
' Queries an Internet option on the specified handle
Declare Function InternetQueryOption Lib "wininet.dll" Alias "InternetQueryOptionA" (ByVal hInternet As Long, ByVal lOption As Long, ByRef sBuffer As Any, ByRef lBufferLength As Long) As Integer
' Returns the version number of Wininet.dll.
Public Const INTERNET_OPTION_VERSION = 40
' Contains the version number of the DLL that contains the Windows Internet
' functions (Wininet.dll). This structure is used when passing the
' INTERNET_OPTION_VERSION flag to the InternetQueryOption function.
Type tWinInetDLLVersion
lMajorVersion As Long
lMinorVersion As Long
End Type
' Adds one or more HTTP request headers to the HTTP request handle.
Declare Function HttpAddRequestHeaders Lib "wininet.dll" Alias "HttpAddRequestHeadersA" (ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal lModifiers As Long) As Integer
' Flags to modify the semantics of this function. Can be a combination of these values:
' Adds the header only if it does not already exist; otherwise, an error is returned.
Public Const HTTP_ADDREQ_FLAG_ADD_IF_NE
' Adds the header if it does not exist. Used with REPLACE.
Public Const HTTP_ADDREQ_FLAG_ADD = &H20000000
' Replaces or removes a header. If the header value is empty and the header is found,
' it is removed. If not empty, the header value is replaced
Public Const HTTP_ADDREQ_FLAG_REPLACE = &H80000000
' Internet Errors
Public Const INTERNET_ERROR_BASE = 12000
Public Const ERROR_INTERNET_OUT_OF_HAND
Public Const ERROR_INTERNET_TIMEOUT = (INTERNET_ERROR_BASE + 2)
Public Const ERROR_INTERNET_EXTENDED_ER
Public Const ERROR_INTERNET_INTERNAL_ER
Public Const ERROR_INTERNET_INVALID_URL
Public Const ERROR_INTERNET_UNRECOGNIZE
Public Const ERROR_INTERNET_NAME_NOT_RE
Public Const ERROR_INTERNET_PROTOCOL_NO
Public Const ERROR_INTERNET_INVALID_OPT
Public Const ERROR_INTERNET_BAD_OPTION_
Public Const ERROR_INTERNET_OPTION_NOT_
Public Const ERROR_INTERNET_SHUTDOWN = (INTERNET_ERROR_BASE + 12)
Public Const ERROR_INTERNET_INCORRECT_U
Public Const ERROR_INTERNET_INCORRECT_P
Public Const ERROR_INTERNET_LOGIN_FAILU
Public Const ERROR_INTERNET_INVALID_OPE
Public Const ERROR_INTERNET_OPERATION_C
Public Const ERROR_INTERNET_INCORRECT_H
Public Const ERROR_INTERNET_INCORRECT_H
Public Const ERROR_INTERNET_NOT_PROXY_R
Public Const ERROR_INTERNET_REGISTRY_VA
Public Const ERROR_INTERNET_BAD_REGISTR
Public Const ERROR_INTERNET_NO_DIRECT_A
Public Const ERROR_INTERNET_NO_CONTEXT = (INTERNET_ERROR_BASE + 24)
Public Const ERROR_INTERNET_NO_CALLBACK
Public Const ERROR_INTERNET_REQUEST_PEN
Public Const ERROR_INTERNET_INCORRECT_F
Public Const ERROR_INTERNET_ITEM_NOT_FO
Public Const ERROR_INTERNET_CANNOT_CONN
Public Const ERROR_INTERNET_CONNECTION_
Public Const ERROR_INTERNET_CONNECTION_
Public Const ERROR_INTERNET_FORCE_RETRY
Public Const ERROR_INTERNET_INVALID_PRO
Public Const ERROR_INTERNET_NEED_UI = (INTERNET_ERROR_BASE + 34)
Public Const ERROR_INTERNET_HANDLE_EXIS
Public Const ERROR_INTERNET_SEC_CERT_DA
Public Const ERROR_INTERNET_SEC_CERT_CN
Public Const ERROR_INTERNET_HTTP_TO_HTT
Public Const ERROR_INTERNET_HTTPS_TO_HT
Public Const ERROR_INTERNET_MIXED_SECUR
Public Const ERROR_INTERNET_CHG_POST_IS
Public Const ERROR_INTERNET_POST_IS_NON
Public Const ERROR_INTERNET_CLIENT_AUTH
Public Const ERROR_INTERNET_INVALID_CA = (INTERNET_ERROR_BASE + 45)
Public Const ERROR_INTERNET_CLIENT_AUTH
Public Const ERROR_INTERNET_ASYNC_THREA
Public Const ERROR_INTERNET_REDIRECT_SC
Public Const ERROR_INTERNET_DIALOG_PEND
Public Const ERROR_INTERNET_RETRY_DIALO
Public Const ERROR_INTERNET_HTTPS_HTTP_
Public Const ERROR_INTERNET_INSERT_CDRO
' FTP API errors
Public Const ERROR_FTP_TRANSFER_IN_PROG
Public Const ERROR_FTP_DROPPED = (INTERNET_ERROR_BASE + 111)
Public Const ERROR_FTP_NO_PASSIVE_MODE = (INTERNET_ERROR_BASE + 112)
' gopher API errors
Public Const ERROR_GOPHER_PROTOCOL_ERRO
Public Const ERROR_GOPHER_NOT_FILE = (INTERNET_ERROR_BASE + 131)
Public Const ERROR_GOPHER_DATA_ERROR = (INTERNET_ERROR_BASE + 132)
Public Const ERROR_GOPHER_END_OF_DATA = (INTERNET_ERROR_BASE + 133)
Public Const ERROR_GOPHER_INVALID_LOCAT
Public Const ERROR_GOPHER_INCORRECT_LOC
Public Const ERROR_GOPHER_NOT_GOPHER_PL
Public Const ERROR_GOPHER_ATTRIBUTE_NOT
Public Const ERROR_GOPHER_UNKNOWN_LOCAT
' HTTP API errors
Public Const ERROR_HTTP_HEADER_NOT_FOUN
Public Const ERROR_HTTP_DOWNLEVEL_SERVE
Public Const ERROR_HTTP_INVALID_SERVER_
Public Const ERROR_HTTP_INVALID_HEADER = (INTERNET_ERROR_BASE + 153)
Public Const ERROR_HTTP_INVALID_QUERY_R
Public Const ERROR_HTTP_HEADER_ALREADY_
Public Const ERROR_HTTP_REDIRECT_FAILED
Public Const ERROR_HTTP_NOT_REDIRECTED = (INTERNET_ERROR_BASE + 160)
Public Const ERROR_HTTP_COOKIE_NEEDS_CO
Public Const ERROR_HTTP_COOKIE_DECLINED
Public Const ERROR_HTTP_REDIRECT_NEEDS_
' additional Internet API error codes
Public Const ERROR_INTERNET_SECURITY_CH
Public Const ERROR_INTERNET_UNABLE_TO_C
Public Const ERROR_INTERNET_TCPIP_NOT_I
Public Const ERROR_INTERNET_DISCONNECTE
Public Const ERROR_INTERNET_SERVER_UNRE
Public Const ERROR_INTERNET_PROXY_SERVE
Public Const ERROR_INTERNET_BAD_AUTO_PR
Public Const ERROR_INTERNET_UNABLE_TO_D
Public Const ERROR_INTERNET_SEC_INVALID
Public Const ERROR_INTERNET_SEC_CERT_RE
' InternetAutodial specific errors
Public Const ERROR_INTERNET_FAILED_DUET
Public Const INTERNET_ERROR_LAST = ERROR_INTERNET_FAILED_DUET
'
' flags common to open functions (not InternetOpen()):
'
Public Const INTERNET_FLAG_RELOAD = &H80000000 ' retrieve the original item
'
' flags for InternetOpenUrl():
'
Public Const INTERNET_FLAG_RAW_DATA = &H40000000 ' FTP/gopher find: receive the item as raw (structured) Data
Public Const INTERNET_FLAG_EXISTING_CON
'
' flags for InternetOpen():
'
Public Const INTERNET_FLAG_ASYNC = &H10000000 ' this request is asynchronous (where supported)
'
' protocol-specific flags:
'
Public Const INTERNET_FLAG_PASSIVE = &H8000000 ' used for FTP connections
'
' additional cache flags
'
Public Const INTERNET_FLAG_NO_CACHE_WRI
Public Const INTERNET_FLAG_DONT_CACHE = INTERNET_FLAG_NO_CACHE_WRI
Public Const INTERNET_FLAG_MAKE_PERSIST
Public Const INTERNET_FLAG_FROM_CACHE = &H1000000 ' use offline semantics
Public Const INTERNET_FLAG_OFFLINE = INTERNET_FLAG_FROM_CACHE
'
' additional flags
'
Public Const INTERNET_FLAG_SECURE = &H800000 ' use PCT/SSL if applicable (HTTP)
Public Const INTERNET_FLAG_KEEP_CONNECT
Public Const INTERNET_FLAG_NO_AUTO_REDI
Public Const INTERNET_FLAG_READ_PREFETC
Public Const INTERNET_FLAG_NO_COOKIES = &H80000 ' no automatic cookie handling
Public Const INTERNET_FLAG_NO_AUTH = &H40000 ' no automatic authentication handling
Public Const INTERNET_FLAG_CACHE_IF_NET
'
' Security Ignore Flags, Allow HttpOpenRequest to overide
' Secure Channel (SSL/PCT) failures of the following types.
'
Public Const INTERNET_FLAG_IGNORE_REDIR
Public Const INTERNET_FLAG_IGNORE_REDIR
Public Const INTERNET_FLAG_IGNORE_CERT_
Public Const INTERNET_FLAG_IGNORE_CERT_
'
' more caching flags
'
Public Const INTERNET_FLAG_RESYNCHRONIZ
Public Const INTERNET_FLAG_HYPERLINK = &H400 ' asking wininet to do hyperlinking semantic which works right for scripts
Public Const INTERNET_FLAG_NO_UI = &H200 ' no cookie popup
Public Const INTERNET_FLAG_PRAGMA_NOCAC
Public Const INTERNET_FLAG_CACHE_ASYNC = &H80 ' ok to perform lazy cache-write
Public Const INTERNET_FLAG_FORMS_SUBMIT
Public Const INTERNET_FLAG_NEED_FILE = &H10 ' need a file for this request
Public Const INTERNET_FLAG_MUST_CACHE_R
'
' flags for FTP
'
Public Const INTERNET_FLAG_TRANSFER_ASC
Public Const INTERNET_FLAG_TRANSFER_BIN
'
' flags field masks
'
Public Const SECURITY_INTERNET_MASK = INTERNET_FLAG_IGNORE_CERT_
Public Const INTERNET_FLAGS_MASK = INTERNET_FLAG_RELOAD Or _
INTERNET_FLAG_RAW_DATA Or INTERNET_FLAG_EXISTING_CON
INTERNET_FLAG_ASYNC Or INTERNET_FLAG_PASSIVE Or _
INTERNET_FLAG_NO_CACHE_WRI
INTERNET_FLAG_FROM_CACHE Or INTERNET_FLAG_SECURE Or _
INTERNET_FLAG_KEEP_CONNECT
INTERNET_FLAG_READ_PREFETC
INTERNET_FLAG_NO_AUTH Or INTERNET_FLAG_CACHE_IF_NET
SECURITY_INTERNET_MASK Or INTERNET_FLAG_RESYNCHRONIZ
INTERNET_FLAG_HYPERLINK Or INTERNET_FLAG_NO_UI Or _
INTERNET_FLAG_PRAGMA_NOCAC
INTERNET_FLAG_FORMS_SUBMIT
INTERNET_FLAG_TRANSFER_BIN
Public Const INTERNET_ERROR_MASK_INSERT
Public Const INTERNET_OPTIONS_MASK = (Not INTERNET_FLAGS_MASK)
'
' common per-API flags (new APIs)
'
Public Const WININET_API_FLAG_ASYNC = &H1 ' force async operation
Public Const WININET_API_FLAG_SYNC = &H4 ' force sync operation
Public Const WININET_API_FLAG_USE_CONTE
'
' INTERNET_NO_CALLBACK - if this value is presented as the dwContext parameter
' then no call-backs will be made for that API
'
Public Const INTERNET_NO_CALLBACK = 0
--------------------------
Here the Get example :
' Envoie une requjte HTTP
' Parametre :
' sServerName = nom du serveur Ex: www.mobiquid.com Attention : Ne pas mettre http://
' iServerPort = port du serveur Ex: 80
' lService = Service internet a utiliser Ex: INTERNET_SERVICE_HTTP
' sQuery = VERB http Ex: GET
' sObjectName = Objet Ex: index.htm
' sUserName = Nom de l'utilisateur (optionel)
' sPassword = Mot de passe (optionel)
' Retourne :
' Resultat HTTP (200 = OK, 404 = Not found, ..., 999 = probleme inconnu, probablement le serveur repond pas
Public Function sendHttpRequest(sServerNam
lService As Long, sQuery As String, sObjectName As String, _
Optional sUsername As String = "", Optional sPassword As String = "") As Integer
Dim lFlags As Long
Dim lContext As Long
Dim hSession As Long
Dim hConnect As Long
Dim hRequest As Long
Dim bRequest As Boolean
Dim closeHandle As Boolean
sObjectName = Replace(sObjectName, "'", "+")
hSession = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONF
hConnect = InternetConnect(hSession, sServerName, iServerPort, sUsername, sPassword, lService, lFlags, lContext)
hRequest = HttpOpenRequest(hConnect, UCase(sQuery), sObjectName, vbNullString, vbNullString, 0, 0, 0)
bRequest = HttpSendRequest(hRequest, vbNullString, 0, vbNullString, 0)
If bRequest = False Then
sendHttpRequest = 999 ' Can't connect to server
closeHandle = InternetCloseHandle(hReque
closeHandle = InternetCloseHandle(hConne
closeHandle = InternetCloseHandle(hSessi
Exit Function
End If
GetQueryInfo(hRequest, 20))
sendHttpRequest = CInt(GetQueryInfo(hRequest
closeHandle = InternetCloseHandle(hReque
closeHandle = InternetCloseHandle(hConne
closeHandle = InternetCloseHandle(hSessi
End Function
--------------------------
Here the post example (post param are in sOption):
' Envoie une requjte HTTP
' Parametre :
' sServerName = nom du serveur Ex: www.mobiquid.com Attention : Ne pas mettre http://
' iServerPort = port du serveur Ex: 80
' lService = Service internet a utiliser Ex: INTERNET_SERVICE_HTTP
' sQuery = VERB http Ex: GET
' sObjectName = Objet Ex: index.htm
' sOption = Parametre post a envoyer
' sData = page html de resultat
' sUserName = Nom de l'utilisateur (optionel)
' sPassword = Mot de passe (optionel)
' Retourne :
' Resultat HTTP (200 = OK, 404 = Not found, ..., 999 = probleme inconnu, probablement le serveur repond pas
Public Function sendSMS(sServerName As String, iServerPort As Integer, _
lService As Long, sQuery As String, sObjectName As String, _
sOption As String, ByRef sData As String, _
Optional sUsername As String = "", Optional sPassword As String = "") As Integer
Dim lFlags As Long
Dim lContext As Long
Dim lOption As Long
Dim hSession As Long
Dim hConnect As Long
Dim hRequest As Long
Dim bRequest As Boolean
Dim closeHandle As Boolean
Dim bDoLoop As Boolean
Dim sReadBuffer As String * 2048
Dim lNumberOfBytesRead As Long
Dim bRet As Boolean
Dim sBuffer As String
Dim sHeader As String
lOption = Len(sOption)
hSession = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONF
hConnect = InternetConnect(hSession, sServerName, iServerPort, sUsername, sPassword, lService, lFlags, lContext)
hRequest = HttpOpenRequest(hConnect, UCase(sQuery), sObjectName, vbNullString, vbNullString, 0, 0, 0)
bRequest = HttpSendRequest(hRequest, vbNullString, 0, sOption, lOption)
If bRequest = False Then
sendSMS = 999
closeHandle = InternetCloseHandle(hReque
closeHandle = InternetCloseHandle(hConne
closeHandle = InternetCloseHandle(hSessi
Exit Function
End If
sendSMS = CInt(GetQueryInfo(hRequest
closeHandle = InternetCloseHandle(hReque
closeHandle = InternetCloseHandle(hConne
closeHandle = InternetCloseHandle(hSessi
End Function
Public Function GetQueryInfo(ByVal hHttpRequest As Long, ByVal iInfoLevel As Long) As String
' Purpose : Retrieves header information
' Parameters : HttpRequest handle, label to put information in, and infolevel flag
' Return val : Success/Failure
' Algorithm : Calls the HttpQueryInfo function and copies result into label
Dim sBuffer As String * 1024
Dim lBufferLength As Long
lBufferLength = Len(sBuffer)
Call HttpQueryInfo(hHttpRequest
GetQueryInfo = Trim$(sBuffer)
End Function
Those example get only the HTTP result code. If you want to get the result page, add this :
bDoLoop = True
While bDoLoop
sReadBuffer = vbNullString
bRet = InternetReadFile(hRequest,
sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)
If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
Wend