There are two options available to you. First, you could include the .dll files we supply as part of the C#.net wrapper library. As they are compiled for .net 2.0 compatability, you can include them to a vb.net project and leverage our wrapper library from there. You can find this code here: https://sourceforge.net/projects/ctctcsharplib/
The other option is you could use the HttpWebRequest object and define your own methods from scratch. All you need to do is set the HttpMethod to PUT or POST and then use the RequestStream object to send the content of your POST or PUT method as the stream input (using a StreamWriter or derived object) to send the body of the request. The C#.net library has a full example of how to do this in C# which can be translated to VB using any number of free C# -> VB code converters.
Hope this helps.
... View more
Hi Marietjie, It looks like you are using the older Site Visitor API for this script. We recommend switching to the new API in order to ensure continued functionality. I have written you a new function that you can use: Public Function AddUserToConstantContactList(ByVal UserEmailAddress As String, ByVal ContactListNumber As Integer) As String
Dim xml As String
xml = "<?xml version='1.0' encoding='utf-8' ?>" & _
"<entry xmlns='http://www.w3.org/2005/Atom'>" & _
"<title type='text'></title>" & _
"<updated>2008-07-23T14:21:06.407Z</updated>" & _
"<author></author>" & _
"<id>data:,none</id>" & _
"<summary type='text'>Contact</summary>" & _
"<content type='application/vnd.ctct+xml'>" & _
"<Contact xmlns='http://ws.constantcontact.com/ns/1.0/'>" & _
"<EmailAddress>" & UserEmailAddress.ToString() & "</EmailAddress>" & _
"<OptInSource>ACTION_BY_CONTACT</OptInSource>" & _
"<ContactLists>" & _
"<ContactList id='http://api.constantcontact.com/ws/customers/dentalladies/lists/" + ContactListNumber.ToString() + "'/>" & _
"</ContactLists>" & _
"</Contact>" & _
"</content>" & _
' Set up the request
Dim request As HttpWebRequest
request = WebRequest.Create("https://api.constantcontact.com/ws/customers/dentalladies/contacts")
Dim byteData As Byte() = UTF8Encoding.UTF8.GetBytes(xml.ToString())
request.Method = "POST"
request.ContentType = "application/atom+xml"
request.ContentLength = byteData.Length
request.Credentials = New NetworkCredential("Your API key%your user name", "your password")
' Send the request
Dim postStream As Stream
postStream = request.GetRequestStream()
postStream.Write(byteData, 0, byteData.Length)
Dim response As HttpWebResponse
response = request.GetResponse()
Catch ex As WebException
End Function Also, the new API uses numbers to specify the list. So, you will need to pass in the number of the list to the function as a string.
... View more
Hi, sorry for asking but I am very new at this. How do I GET the XML from the url https://api.constantcontact.com/ws/customers/USERN AMEemail@example.com ? if I do it with my username then I get a 401 error? What will the code be for this? Thanks
... View more