I tried to get a hold of the method getListMembers using the following code
string
_nextChunk = "";
IList<ContactList> currentContactLists = Utility.GetUserContactListCollection( authdata, out _nextChunk);
Response.Write("<b>Contact List Name</b><br>");
for( int c=0; c < currentContactLists.Count; c++ )
{
ContactList contactList = currentContactLists[ c ];
Response.Write( contactList.Id + "<br>");
Response.Write( contactList.Name + "<br>");
Response.Write( contactList.ShortName + "<br>");
Response.Write( contactList.Link + "<br>");
Response.Write( contactList.SortOrder + "<br>");
ContactSystemList sys = contactList.SystemList;
IList<Contact> contactMemberList = Utility.getListMembers( contactList.Link, authdata, out _nextChunk );
Response.Write("<br>");
Response.Write("<b>Contacts</b><br>");
for( int z=0; z < contactMemberList.Count; z++ )
{
Contact contactMember = (Contact)contactMemberList[ z ];
Response.Write( contactMember.FirstName + " " + contactMember.LastName + ", " + contactMember.EmailAddress + "<br>");
}
Response.Write("<br><br>");
}
Response.Write("<br>");
I was not able to access it and it kept saying it wasn't part of the Utility class even though in the code it existed.
I am using version 1.0.0.0 APIs if that helps for the following DLLs:
ConstantContactBO
ConstantContactUtility
My only work around was to take that method out of the source code and place it in my class in order to make it work.
I would like to use it correctly vs using it like I have it now.
Thanks in advance.
Hi,
I ran your code successfully. I am using the following libraries (though I'm sure not all of them are necessary here):
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ConstantContactBO;
using ConstantContactUtility;
I put your test code in Form1.cs (inside the Debug form in our .NET library), so it should have the correct settings and references straight out of the gate, but that would still be something to check. Are you putting your code inside Form1.cs, or somewhere else? It sounds like it can see Utility.cs, and I did double check to make sure that getListMembers is a public class so I'm at a bit of a loss as to why it's not working as written for you.
Best Regards,
Shannon W.
API Support Specialist
Hi,
After closer inspection of the wrapper, I believe that the dll's were not updated like the source files (.cs files, which I am using in my application) when the wrapper was last updated. We will try to update github soon with that change.
Best Regards,
Shannon W.
API Support Specialist
Thanks for the update.
I am running into a couple of other issues
1. How do I pull more than 50 contact list members? I am using the code above but only 50 show up.
I understand that you use nextChunk but I want to pull the entire list at once instead of chunks is this possible?
2. I am trying to add a Contact using the following code but when I look at the Contact List (1) to see if it has been
added I still only see 1 contact instead of 2. What am I doing wrong?
// Contact add/update to an existing Contact List
string _emailAddress = "test11212012@test.com";
// Add the email addresses to a list
List<string> email = new List<string>();
email.Add(_emailAddress);
// Search for the email
IList<Contact> myContact = Utility.SearchContactByEmail(authdata, email, out _nextChunk);
Response.Write("myContact = " + myContact.Count + "<br>");
if( myContact.Count == 0 )
{
//Contact Does not exist, create new contact
Contact thisContact = new Contact();
thisContact.EmailAddress = _emailAddress;
//Add Lists to Contact
ContactOptInList newList = new ContactOptInList();
newList.ContactList = new ContactList("1"); //Contact list you want to add them to
thisContact.ContactLists.Add(newList);
thisContact.OptInSource = ContactOptSource.ActionByContact;
//Add contact
Utility.CreateNewContact(authdata, thisContact);
}
else
{
//Contact does exist, update existing
//Get Contact by ID
Contact thisContact = Utility.GetContactDetailsById(authdata, myContact[0].Id);
//Add Lists
ContactOptInList newList = new ContactOptInList();
newList.ContactList = new ContactList("1"); //Contact list you want to add them to
thisContact.ContactLists.Add(newList);
thisContact.OptInSource = ContactOptSource.ActionByContact;
//Update contact
Utility.UpdateContactFullForm(authdata, thisContact);
}
Thanks in advance
Actually I was able to find the email address in issue #2. It is awaiting confirmation.
How does that work or how long does it take to be confirmed so I can begin to see it my list?
Thanks
Hi,
If you have confirmed opt in ON in your account (it sounds like you do), then we send an email to the contact and they have to click on the link to confirm their subscription to be put into active status.
Sorry, there isn't a way to get more than 50 results at once. The APi can only return 50 results at a time.
Best Regards,
Shannon W.
API Support Specialist