The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

XML opt-in bug?

Highlighted
New Member

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.


==========


 


include_once('cc_class.php');


$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');

1 REPLY 1
Highlighted
Employee

Re: XML opt-in bug?

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

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured