We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

XML opt-in bug?


XML opt-in bug?

I am using the code below on my website for people to opt-into my lists. The code works, however when I test an opt-in, and then go to my account and delete the email address from the list, subsequent attempts from the same person to opt-into the same list will fail. Thanks for looking into this.




$ccOBJ = new ConstantContact();


$names = explode(" ", $_POST, 2);


$xml = "<entry xmlns='http://www.w3.org/2005/Atom'>;<title type='text'></title><updated>2008-07-23T14:21:06.407Z</updated><author></author><id>data:,none</id><summary type='text'>Contact</summary><content type='application/vnd.ctct+xml'><Contact xmlns='http://ws.constantcontact.com/ns/1.0/'>;<EmailAddress>";

$xml .= $_POST;

$xml .="</EmailAddress><FirstName>";

$xml .= $names;

$xml .= "</FirstName><LastName>";

$xml .= $names;

$xml .= "</LastName><OptInSource>ACTION_BY_CONTACT</OptInSource><ContactLists><ContactList id='http://api.constantcontact.com/ws/customers/lieselinsb/lists/5' />";


// do logic here if we need to add to other lists


$xml .= "</ContactLists></Contact></content></entry>";


$call = $ccOBJ->apiPath.'/contacts';

$return = $ccOBJ->doServerCall($call, $xml, 'POST');


Once a contact is created in Constant Contact, they cannot be added to further lists using an http Post. In order to add this person to additional lists, you would need to update that contact with XML indicating that they are subscribed to additional lists. For more information on this I would recommend viewing Updating Contact Information.


If you deleted the contact to opt them out, you would need to opt that subscriber back in by modifying their contact list subscriptions using the appropriate opt in source (ACTION_BY_CONTACT). Please see Opting-in a Contact for more information regarding this.


I hope this helps to clear up any points of confusion. If you have any questions or concerns regarding this, please let us know and we will be happy to help.

David J

Developer Portal

View API documentation, code samples, get your API key.

Visit Page