Before attempting to add a new contact, query_contacts() is called to see if the contact already exists. The current code looks for a feed/entry tag in the response to the "contacts?email="..." Constant Contacts API call . If this tag is non-empty, then it assumes the contact exists and cannot be added.
This test is necessary but not sufficient. There is an odd case where a feed/entry tag is returned with contact information and the feed/entry/content/Contact/Status tag == 'Visitor'. In this case, confirmed with Constant Contact support (http://developer.constantcontact.com/node/1396), the "the contact has had an email forwarded to them from someone on your list" and the contact can be added.
So, the more robust test is
a) If no feed/entry (or feed/entry/id) tag, then contact does not exist and can be added.
b) If there is a feed/entry tag, check for a feed/entry/Contact/Status tag. If this tag is "Visitor", then the contact can be added. If this tag does not exist or is other than "Visitor", then the contact cannot be added (POST-ed).
The new code in query_contacts is:
$_contact = (isset($xml['feed']['entry'])) ? $xml['feed']['entry'] : false;
// parse into nicer array
if(is_array($_contact)):
// NEW CODE: Check if Status == 'Visitor'. If so, we can still add this contact.
if (isset($_contact['content']['Contact']['Status']) && strtolower($_contact['content']['Contact']['Status']) == 'visitor'):
return false;
endif;
$id = $this->get_id_from_link($_contact['link_attr']['href']);
$contact = $_contact['content']['Contact'];
$contact['id'] = $id;
endif;
I've tested this code on such an entry and I was successfully able to add the contact that was marked <Status>Visitor</Status>
Comments
Comment #1
erehm commentedFYi, query_contacts() is found in class.cc.php.
Comment #2
erehm commentedConstant Contact has decided to change their API so as to NOT expose the Status == Visitor contacts (which aren't really contacts!). See http://developer.constantcontact.com/node/1396
So, the logic above will *not* be needed and the bug is closed.