node from secured Constant Contact XML (1 Viewer)

mjcaestecker

Registered User.
Local time
Yesterday, 17:52
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
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 20:52
Joined
Jan 23, 2006
Messages
15,394
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
 

mjcaestecker

Registered User.
Local time
Yesterday, 17:52
Joined
Aug 17, 2012
Messages
25
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
 

spikepl

Eledittingent Beliped
Local time
Today, 02:52
Joined
Nov 3, 2010
Messages
6,142
GetContactInfo.responseXML gets you the XML doc, not a string
 

mjcaestecker

Registered User.
Local time
Yesterday, 17:52
Joined
Aug 17, 2012
Messages
25
Spikepl, could I use GetContactInfo.responseXML to get a single node from the document?
 

Users who are viewing this thread

Top Bottom