MartyConnelly
martyconnelly at shaw.ca
Fri May 6 15:33:34 CDT 2005
Don't misstype Google.com that goes to a baaad place too.
Anyone who went there should run adaware just in case you picked up ezula
An annoying tracker.
This should work returns an html string you will have to parse it
afterwards.
if site is expecting UTF-8 rather than urlencode values, you may have to
use winhttp
The urlencode changes values after "? " from characters like space to "%20"
Public Sub quick_Click(UserName As String, Password As String)
'need reference to xml 3.0 or 4.0
Dim objHTTP As New MSXML2.XMLHTTP
Dim strWebPage As String
Dim sFormData As String
On Error Resume Next
'Retrieve Web Page
strWebPage = "https://ebay.com"
objHTTP.Open "POST", strWebPage, False, UserName, Password
' stick in your web page url above , file type can be anything asp
txt xml html etc.
'depends partially on content type
' generally request header is first line below for forms
'objHttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
'objHttp.setRequestHeader "Content-Type", "text/xml"
'objHttp.setRequestHeader "Content-Type", "multipart/form-data"
objHTTP.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
'Post variables depending on html form
sFormData = "do_action=saveSelect&pageChanged=true"
sFormData = URLEncode(SFormData)
objHTTP.send sFormData
'Check status of page
If Err.Number Or objHTTP.status <> "200" Then
MsgBox Err.Number & Err.Description
MsgBox "Cannot retrieve page!"
'Exit Sub
End If
' look at the response
Debug.Print objHTTP.getAllResponseHeaders
Debug.Print objHTTP.statusText
Debug.Print objHTTP.responseText
'Debug.Print objHTTP.xml
'Pass Response back from Server
Debug.Print objHTTP.responseText
End Sub
'************************************************************
' Name: URLEncode and URLDecode functions
' NOTE: These URLEncode and URLDecode functions should be
' rewritten in C/C++, or come up with a better algorithm
' /mto at softtools.dk
'************************************************************
Private Function URLEncode(ByVal Str As String) As String
Dim i As Long
Dim cChar As String
Dim sSpecial As String
Dim sResult As String
Dim sTempResult() As String
ReDim sTempResult(Len(Str))
For i = 1 To Len(Str)
cChar = Mid$(Str, i, 1)
' a-z and A-Z is not touched
If Asc(cChar) = 32 Then ' Space
sTempResult(i) = "+"
Else
If ((Asc(cChar) >= 97 And Asc(cChar) <= 122) Or _
(Asc(cChar) >= 65 And Asc(cChar) <= 90) Or _
(Asc(cChar) >= 48 And Asc(cChar) <= 57)) Then
sTempResult(i) = cChar
Else
sTempResult(i) = "%" & Hex(Asc(cChar))
End If
End If
Next i
URLEncode = Join(sTempResult, "")
End Function
'routine join just case runnning from Access97
Public Function Join(varArray As Variant, _
Optional strDelimiter As String = "") As String
'-----------------------------------------------------------
' Inputs: An array of strings and an optional delimiter
' Outputs: A concatenated string assembled from the
' array elements, delimited by the optional
' delimiter character
' Created By: JLV 09/05/01
' Last Revised: 09/05/01
' ** Duplicates the functionality of the VB 6 JOIN function
'-----------------------------------------------------------
Dim intL As Integer, intU As Integer, intI As Integer
Dim strWork As String
If Not IsArray(varArray) Then Exit Function
intL = LBound(varArray)
intU = UBound(varArray)
strWork = varArray(intL)
For intI = intL + 1 To intU
strWork = strWork & strDelimiter & varArray(intI)
Next intI
Join = strWork
End Function
Andy Lacey wrote:
>Oh my God!!! I'm SO sorry. What the hell happened??? Oh God I realise now.
>The script had a company name I didn't want to publish. I replaced it with
>xxx and did this. I'm SOOOOOOOOOOO sorry. It was a totally serious question
>and a real and very embarassing mistake. I didn't even imagine anyone would
>treat it as a link/ the question was how to make the request. God I'd better
>find a hole and crawl into it.
>
>-- Andy Lacey
>http://www.minstersystems.co.uk
>
>
>
>>-----Original Message-----
>>From: accessd-bounces at databaseadvisors.com
>>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
>>Charlotte Foust
>>Sent: 06 May 2005 17:44
>>To: Access Developers discussion and problem solving
>>Subject: RE: [AccessD] HTTP Get Request from Access?
>>
>>
>>Is this supposed to be Friday humor? That is NOT an amusing redirect!
>>
>>Charlotte Foust
>>
>>
>>-----Original Message-----
>>From: Andy Lacey [mailto:andy at minstersystems.co.uk]
>>Sent: Friday, May 06, 2005 8:34 AM
>>To: Access Developers discussion and problem solving
>>Subject: [AccessD] HTTP Get Request from Access?
>>
>>
>>I have no idea whatsoever if this is possible, so feel free
>>to snigger if the question's ridiculous.
>>
>>I have a requirement to send, from an Access97 app, an HTTP
>>request along the following lines
>>http://www.xxx.co.uk/scripts/sendsms.php?username=youruser&pas
>>
>>
>sword=your
>pass¶m1=xxxxxxxxx¶m2=Testing
>
>receiving back a response. Can this be done, and if so anyone got any code
>or know where to get it?
>
>--
>Andy Lacey
>http://www.minstersystems.co.uk
>
>
>________________________________________________
>Message sent using UebiMiau 2.7.2
>
>
>
--
Marty Connelly
Victoria, B.C.
Canada