Hi Shannon_W: Thanks for help. I was able to switch my PHP version to 5.3. After that, I was able to add a NEW contact successfully using the codes shown below. HOWEVRE, I retried it again to add the SAME contact, I go the following error message: "was added to your new listd” “Constant Contact HTTP Request Exception: Error 400: The request contains errors in the common Atom sections, which lie outside or , such as , , or ." Any suggestion on how to fix this? --------------------------------------------------------- ---------------------- Also, I tried following 4 cases, but for all 4 cases, it shows the contact is added by SITE OWNER. 1. Did not set $contactObj->optInSource 2. $contactObj->optInSource = "ACTION_BY_CUSTOMER"; 3. $contactObj->optInSource = 'ACTION_BY_CUSTOMER'; 4. $contactObj->optInSource = ACTION_BY_CUSTOMER; What shall I do so that the contact can be shown as added by CONTACT (not SITE OWNER)? ------------ --------------------------------------------------------------- Thanks. /* ================================================= */ include ('wrapper/ConstantContact.php'); // Connecting to your account $ConstantContact = new ConstantContact("basic", $apikey, $username, $password); // Get potential contact lists $lists = $ConstantContact->getLists(); // Lists are returned in multidimentional arrays 0 being the list, and 1 being the next50 // Search for our new Email address $search = $ConstantContact->searchContactsByEmail($emailAddress); // If the search didnt return a contact object if($search == false) { echo "Created new contact"; // Create a new Contact Object to store data into $contactObj = new Contact(); // Adding multiple lists to this new Contact Object $contactObj->lists = array($lists['lists'][0]->id, $lists['lists'][1]->id); // Set the email address $contactObj->emailAddress = $emailAddress; // Create the Contact and DONE $Contact = $ConstantContact->addContact($contactObj); echo $contactObj->emailaddress; } // Otherwise we update our existing else { echo $contactObj->emailaddress . " was added to your new list"; // Gather data from our previous search and store it into a data type $contactObj = $ConstantContact->getContactDetails($search[0]); // We need to get the old list and add a new list to it as // this request requires a PUT and will remove the lists // as they are stored in an array array_push($contactObj->lists, $lists['lists'][3]->id ); // Update the contact and DONE $UpdateContact = $ConstantContact->updateContact($contactObj); }
... View more