Opting back in a contact on Do Not Mail list doesn't work.

BillT
Retail

Opting back in a contact on Do Not Mail list doesn't work.

I've attempted to set up our custom signup form (http://georgesmusic.com/pages/newsletter) to opt contacts back in who are on the Do Not Mail list, based on the API documentation here: http://community.constantcontact.com/t5/Documentation/Opting-in-a-Contact/ba-p/25115

 

I've had no luck getting it to work. The user stays on the Do Not Mail list, and it sends them a Welcome email, instead of a Resubscribe confirmation.

 

Here is the code generating the XML being sent:

 

$postdata = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>
<entry xmlns="http://www.w3.org/2005/Atom">';
if ($_POST['id'])	$postdata .= '
  <id>http://api.constantcontact.com/ws/customers/btrevena/contacts/'.$_POST['id'].'</id>';
else	$postdata .= '
  <id>data:,none</id>';
$postdata .= '
  <title type="text">Contact: '.$_POST['email'].'</title>
  <updated>'.date('c').'</updated>
  <author>
    <name>Constant Contact</name>
  </author>
  <content type="application/vnd.ctct+xml">
    <Contact xmlns="http://ws.constantcontact.com/ns/1.0/"';
if ($_POST['id'])
	$postdata .= ' id="http://api.constantcontact.com/ws/customers/btrevena/contacts/'.$_POST['id'].'"';
$postdata .= '>
      <Status>Active</Status>
      <EmailAddress>'.$_POST['email'].'</EmailAddress>
      <FirstName>'.$_POST['first'].'</FirstName>
      <LastName>'.$_POST['last'].'</LastName>
      <OptInSource>ACTION_BY_CONTACT</OptInSource>
      <ContactLists>';
foreach($idList as $list) {
        $postdata .= '
        <ContactList id="http://api.constantcontact.com/ws/customers/btrevena/lists/'.$list.'"></ContactList>'; }
$postdata .= '
      </ContactLists>
    </Contact>
  </content>
</entry>';

 It sends OptInSource as ACTION_BY_CONTACT, and a list of lists based on the form.

Anything look wrong here that I need to change, that might fix our issue?

Thanks

1 REPLY 1
Ryan_D
Employee

Hey,

 

What response code is being passed back?  Is it successful or is it return an error code?

Ryan Davis
Quality Engineer
Developer Portal

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

Visit Page