cancel
Showing results for 
Search instead for 
Did you mean: 

Please help getting started

Occasional Contributor

Please help getting started

I'm looking to write a VB.Net application using the API. I want to read information from a database and import a list of contacts to Constant Contact.

I got a API Key and a shared secret.  I have no idea what those are for.  Where do I download the API?  Looks like there are not any VB.Net code samples anywhere here.  What's the purpose of these Keys?  I don't see any documentation on how to use the Keys or accessing the API.  Please help getting started with my app.

 

Thanks so much  

6 REPLIES 6
Honored Contributor

Re: Please help getting started

Hello!

 

At present we do not have any code or samples written in VB.NET, but we do have a library which is created in C# for .NET 4.0+. If you were to use Visual Studio and build this library as a DLL, you could use all of the methods and classes provided in your VB.NET application.

 

To get started, the first things you will need are an API Key and Access Token. the API Key will identify your application, and the Access Token serves as a replacement for the username/password to connect with a Constant Contact account. To get your API Key, you will need to create a Constant Contact developer Account (It's separate from a normal Constant Contact account, and it's free!). Once you've created the account, you can then register for an API key and get your access token. You can complete all of this by following the first three steps found here: https://constantcontact.mashery.com/

 

In order to get the .NET library that is available, you will want to visit our Libraries page which can be found on our developer site here: http://developer.constantcontact.com/libraries/libraries.html

 

It is also worth noting that our .NET code library does include samples that are written in C# which demonstrate some of the basic usage of the library.

 

If you have any questions or any issues, please feel free to reply here!

 

Sincerely,

Elijah G.
API Support Engineer
Occasional Contributor

Re: Please help getting started

Thank you Elijah,

 

I got the C# code and compiled the code to make the CTCT.dll.  I took VB in school many years ago, so it's the only language I know.  I work for a small school.  I am tasked to come up with a way to get student information from our database and pass the first name, last name and email to a Constant Contact group.  Where in the code I downloaded (CTCTWrapper_Contact.sln) can I find a sample on how to pass a list of records to a new group?  I'm guessing I have to create some sort of csv file or text file first and pass that through the API?  Or can I run a query in VB and loop through that to pass each record to a group.

 

Thanks for all your help.

 

 

Honored Contributor

Re: Please help getting started

Hello,

 

If you're simply looking to add the contacts to a specific list/group in Constant Contact, there are some methods and classes in the .NET SDK that can help you out a great deal. Here is a sample snippet of code that would loop through a set of data and create a contact for each person in the set:

 

        Dim _contstantContact As CTCT.ConstantContact
        Dim contactsActivity As CTCT.Components.Activities.AddContacts
        Dim contactData As CTCT.Components.Activities.AddContactsImportData
        Dim contactsToAdd As List(Of CTCT.Components.Activities.AddContactsImportData)
        Dim lists As List(Of String)
        Dim columns As List(Of String)

        lists.Add("LISTID")
        columns.Add("EMAIL")
        columns.Add("FIRST NAME")
        columns.Add("LAST NAME")

        _contstantContact = New CTCT.ConstantContact("APIKEY", "ACCESSTOKEN")
        ' The Contact class and Contacts collection are made up for this purposes of this sample.
' If you have a method of fetching info from a database, you would use that information
' in this loop For Each Contact In Contacts contactData = New CTCT.Components.Activities.AddContactsImportData contactData.EmailAddresses.Add(Contact.email) contactData.FirstName = Contact.firstName contactData.LastName = Contact.fastName contactsToAdd.Add(contactData) Next _contstantContact.CreateAddContactsActivity(New CTCT.Components.Activities.AddContacts(contactsToAdd, lists, columns))

 

This code uses the bulk activity functions of our API, so these will be processed as a batch usually within just a few minutes of being sent to us.

 

If you have any questions or issues, please let me know!

 

Sincerely,

Elijah G.
API Support Engineer
Occasional Contributor

Re: Please help getting started

Hello Elijah,

 

Thanks so much!  If I have a list called "TestList", would I put that in the following code?...

 

lists.Add("TestList")

 

Other than that, I think the rest is pretty straight forward.  

 

**Edit*** from above

 

I'm getting the following error code..

 

"http.status.authentication.invalid_token:Invalid access token: 'my access token goes here. edited out for obvioius reasons'  "

 

What would cause this error?  Is there someone I need to contact?

 

**End Edit****

 

Thanks so much.

Occasional Contributor

Re: Please help getting started

Now Im getting a "activity.field.list_id.invalid:Contact List ID Email list does not exist.  " error.

 

Not sure why.  I also attached a image of the Application Name.  Is there something wrong with the lists?  Please let me know

 

Here's the code..

 

Dim _contstantContact As CTCT.ConstantContact
Dim contactsActivity As CTCT.Components.Activities.AddContacts
Dim contactData As CTCT.Components.Activities.AddContactsImportData
Dim contactsToAdd As New List(Of CTCT.Components.Activities.AddContactsImportData)
Dim lists As New List(Of String)
Dim columns As New List(Of String)

_contstantContact = New CTCT.ConstantContact("api key", "token")

lists.Add("Email list")
columns.Add("EMAIL")
columns.Add("FIRST NAME")
columns.Add("LAST NAME")


' The Contact class and Contacts collection are made up for this purposes of this sample.
' If you have a method of fetching info from a database, you would use that information
' in this loop
'For Each Contact In Contacts
' contactData = New CTCT.Components.Activities.AddContactsImportData
' contactData.EmailAddresses.Add(Contact.email)
' contactData.FirstName = Contact.firstName
' contactData.LastName = Contact.fastName
' contactsToAdd.Add(contactData)
'Next

'Test new user
Try
contactData = New CTCT.Components.Activities.AddContactsImportData
contactData.EmailAddresses.Add("test@gmail.com")
contactData.FirstName = "First"
contactData.LastName = "Last"
contactsToAdd.Add(contactData)
Catch ex As Exception
MsgBox(ex.Message)
End Try

Try
_contstantContact.CreateAddContactsActivity(New CTCT.Components.Activities.AddContacts(contactsToAdd, lists, columns))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub


appname.JPG
CTCT Employee

Re: Please help getting started

Hi Steve,

 

I just responded to your email about this.

 

Best Regards,
Shannon Wallace
Partner API Support Engineer