node from secured Constant Contact XML

mjcaestecker

Registered User.
Local time
Today, 05:39
Joined
Aug 17, 2012
Messages
25
Greetings All,

I've got this code to try and access some information from an XML file on Contant Contact's server. I can open the xml file in my internet browser, but only after i input the username and password. is it possible to modify what's below to include a username and password? I've replaced the information in brackets to protect my clients' information.

Me!XMLprint is a textbox so I can see what the code is returning.

Code:
Private Sub GetInfo_Click()
    Dim doc As MSXML2.DOMDocument
    Set doc = New MSXML2.DOMDocument

    doc.async = False

    doc.Load ("https://api.constantcontact.com/ws/customers/{username}/contacts/{contactID#}")

    Me!XMLprint = doc.selectSingleNode("/entry/author/name").Text
End Sub

-Martin
 
You could try this (not tested)

Private Sub GetInfo_Click()
Dim doc As MSXML2.DOMDocument
Set doc = New MSXML2.DOMDocument
Dim MyUserName as string
Dim MyContactNumber as string
MyUsername ="Put the username here"
MyContactNumber= "Put your contact number here"

doc.async = False

doc.Load ("https://api.constantcontact.com/ws/customers/" & MyUserName &"/contacts/" & MyContactNumber )

Me!XMLprint = doc.selectSingleNode("/entry/author/name").Text
End Sub
 
I gave what you posted a try, but didn't quite solve the problem. I did some more research and found a solution (shown below). This allows me to convert the xml into a string (note the authentification credentials) and then manipulate the string with some more code to extract the info I wanted. The URL is now imported into the function and already has username and customer ID applied to it. This particular code will not let me do a .selectSingleNode command for some reason.

Code:
Public Function ExecuteWebRequest(url As String) As String
'Following code converts xml into a string based on input url
    Dim GetContactInfo As Object
    Dim MyUserName as String
    Dim MyPassword as String
    MyUserName = "Blah"
    MyPassword = "Blah"
    
    Set GetContactInfo = CreateObject("MSXML2.XMLHTTP")
    GetContactInfo.Open "GET", url, False, MyUserName, MyPassword
    GetContactInfo.send
    ExecuteWebRequest = GetContactInfo.responseText
    
    Set GetContactInfo = Nothing
End Function
 
GetContactInfo.responseXML gets you the XML doc, not a string
 
Spikepl, could I use GetContactInfo.responseXML to get a single node from the document?
 

Users who are viewing this thread

Back
Top Bottom