Your code is EXACTLY what I was looking for and really should be included in the CTCT-OAuth2 wrapper files -- espcially the line that specifies how to call basic authentication. The documentation in the config.php file is just plain confusing -- so thank you! Still, I have a concern about the last part of your code where you appear to repair something about the list that you searched. If I don't need to update existing emails -- and only add new ones do I need this code? For my purposes, if the email already exists in the contact list, I don't need to do anything. // Otherwise we update our existing contact
else
{
// 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'][1]->id );
//Set the opt in value
$contactObj->optInSource = "ACTION_BY_CONTACT";
// Update the contact and DONE
$UpdateContact = $ConstantContact->updateContact($contactObj);
echo ("Contact updated.");
}
... View more