Hello there !
I am using API to add my contact form information in specific lists. I submitted the form by selecting list1, And next time i submitted the form by selecting list2. I used same email id but different lists. But it's not allowing. I should add this email in different lists. Please suggest me what should i do in this case ?
Help will be highly appreciated !
When you are adding contacts through the Constant Contact API, there are two thing to keep in mind:
1. When you are adding a new contact, it is sent as a POST request to Constant Contact. However, when you want to make a change to a contact that has already been added, you must submit it as a PUT request instead.
2. When you are adding a contact to Constant Contact, you do not need to submit the contact once per list. You can specify all of the lists at once when the contact is being added.
You can read more about creating contacts here: http://community.constantcontact.com/t5/Documentation/Creating-a-Contact/ba-p/25059
Also, if you do still need more assistance with creating and updating your contacts, it would be helpful if you could reply and include the code that is being used to submit the information to Constant Contact. Please remember to remove any sensitive information if you do post your code as this is a public forum.
Tier 2 Support
Thanks for your reply on my question !
I have a contact form in my website. I have given lists in select box(ie: list1, list2, list3 etc....). Now user submitted the form will all the details and select list1, list2 at this time. I can insert these details into my constant contact list1,list2.
In future the same user comes to my site and tried to submit the form with same email id but select different list(ie: list3) at this time. In this case constant contact is not allowing to add duplicate entry.
Please suggest me what should i do in this case?
If i try to update the list3 for same email, then i will lose rest of the details like notes(Which describes purpose of contact us from our website). Please suggest me ?
In a case like this where a contact would come and input their information again, what you would want to do is use a GET request to the API to collect the contact's information before submitting an update. Then you can add the new list (list 3) to the existing lists and submit the contact. This way the information is updated rather than overwritten.
As an example, it would work something like this:
- Send a GET request to Constant Contact API and check if firstname.lastname@example.org is already an existing contact
- If they are, perform a second GET request to obtain the contact's details. This will include the lists that they are already a member of.
- Add any updated information to the existing contact information and submit the new data as a PUT request. This will update the record stored in Constant Contact.
If you have any questions about this, please reply to this post and I will be happy to assist you!
Tier 2 Support
Thanks for giving quick reply !
Actually i am using ctct_php_library-master to add and update the contact information.
For adding : $ConstantContact->addContact($Contact);
For updating: $ConstantContact->updateContact($Contact);
It's working fine for adding contact information. But it's giving an error while using updateContact(). The error is like: Method not allowed and response code is 405.
Can you please help me to update contact information in Lists?
And also please provide sample code for this, So that it help me more.
If you are receiving an error 405 when trying to update a contact, that is likely related to an issue with the contact data that is being submitted to the updateContact method. Can you provide an example of the code that is creating the $Contact variable and populating the data?
Tier 2 Support
Below is my code which i am using for update existed contact !
$Contact = new Contact();
$Contact->emailAddress = 'email@example.com';
$Contact->firstName = $_POST['first_name'];
$Contact->lastName = $_POST['last_name'];
$Contact->lists = $_POST['lists'];
$Contact->notes = $_POST['contact_message'];
$Contact->optInSource = 'ACTION_BY_CONTACT';
$response = $ConstantContact->updateContact($Contact);
Please help me in this !
When you want to update an existing contact, the firs thing to do is search and see if the contact already exists. Once you confirm that the contact exists, you can then add your updated information to the existing contact an update it. I have included an exmaple using your code below.
$results = $ConstantContact->searchContactsByEmail(firstname.lastname@example.org); $Contact = $results; $Contact->firstName = $_POST['first_name']; $Contact->lastName = $_POST['last_name']; $Contact->lists = array_merge($Contact->lists,$_POST['lists']); // Adding the array_merge here will add to your exists lists, rather than $Contact->notes = $_POST['contact_message']; $Contact->optInSource = 'ACTION_BY_CONTACT'; $response = $ConstantContact->updateContact($Contact);
What this will do is to collect all of the existing contact information and add the changes. When you are using the updateContact method, you need to have a full contact's information or else it will fail. ONe thing you will likely want to do is add some verification to this code so that it will make sure a contact exists before trying to update it. You could do that by checking for a $Contact->emailAddress field since it will only be set when a contact is successfully fetched.
Feel free to reply if you do have additional questions for me.
Tier 2 Support
View API documentation, code samples, get your API key.Visit Page
We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...Read More