Hi, I'm using the API v2. I am able to POST new contact name and email info but not address info. I am using a the PHP-sdk with a custom HTML form. The relevant code is as follows:
$contact = new Contact();
$contact->last_name = $_POST['name'];
$address = new Address();
$address->address_type = "UNKNOWN";
$address->line1 = $_POST['street'];
$address->city = $_POST['city'];
$address->state_code = $_POST['state'];
$address->postal_code = $_POST['zip'];
$customField = new CustomField();
$customField->name = "CustomField2";
$customField->value = "CustomFieldValue";
Neither static strings (e.g. CustomField2) nor dynamic values ($_POST['some_value']) will POST to a new contact. The name and email will successfully POST, however.
https://gist.github.com/dsjellz/5562021 this was the only help I could find and it does not work. Please advise.
I wanted to post here to let you know that I am researching this issue for you to find an answer to your question. Would it be possible to include the code where you are actually submitting the contact to Constant Contact? If there is sensitive code you are concerned about sharing here in the forums, please feel free to send us an email to firstname.lastname@example.org with the details.
I will follow up here tomorrow with my findings for you.
API Support Specialist
I just personally tested the sample code provided above and was successfully able to add a contact with a custom field and an address. Is it possible to decribe the specifics of what is happening for you, and potentially a sample of the code that is being used to create the contact?
Here is a sample of what works for me:
$contact = new Contact(); $contact->addEmail("email@example.com"); $contact->addList("LISTID"); $contact->last_name = "last"; $address = new Address(); $address->address_type = "UNKNOWN"; $address->line1 = "Street Name"; $address->city = "City"; $address->state_code = "MA"; $address->postal_code = "01720"; $contact->addAddress($address); $customField = new CustomField(); $customField->name = "CustomField2"; $customField->value = "CustomFieldValue"; $contact->addCustomField($customField); $cc->addContact(ACCESS_TOKEN, $contact);
View API documentation, code samples, get your API key.Visit Page
The holidays have come and gone. For many seasonal businesses, this means the rush of shoppers has decreased as well. Instead of turning off the lights and waiting for spring, make your email marketi...See Article