Thanks to help in the community I am using the correct CC wrapper in PHP and can add a user to all my lists, howevewr I'm having a problem adding to a specific list. I'm comparing a list name to a set cookie and using that to get the name of the desired list to add to. That much is working. The problem I am having is trying to add to that specific list. I have code to add to the first two lists, whatever they may be (you can see that commented out in the code below). But I need to be able to add to my specifc list. However when I try that I get warnings that let me know that the list isn't valid. Here is the code: $ConstantContact = new ConstantContact("basic", "key", "usr", "pwd");
//Get potential contact lists
$lists = $ConstantContact->getLists();
$x = count($lists);
$listtoadd = "General Interest"; //the default list
//the FOR and IF loops sets $listtoadd to match a set cookie
for ($i=0;$i<$x;$i++)
{
if ($lists['lists'][$i]->name == $_COOKIE['your-selected-location']) {$listtoadd = $lists['lists'][$i]->id;}
}
$contactObj = new Contact(); //IF I DO THE NEXT LINE INSTEAD, IT ADDS TO BOTH LISTS CORRECTLY // $contactObj->lists = array($lists['lists'][0]->id, $lists['lists'][1]->id);
$contactObj->lists = $listtoadd;
$contactObj->emailAddress = $emailaddress;
// Create the contact
$Contact = $ConstantContact->addContact($contactObj); I did check that the $listtoadd var holds the following: http://api.constantcontact.com/ws/customers/[user]/lists/2 Any thoughts on what I'm doing wrong here? I'm thinking it's something simple that I am missing. While I'm at it, is there a graceful way to handle potential errors from: $Contact = $ConstantContact->addContact($contactObj); I am doing some checking on the front end for proper email formation but dont want to show my end users a potential PHP warning or error. Thanks! Chris
... View more