My challenge is as follows:
I need to drive a contact addition from my PHPurchase checkout page. I have a form field for an email address, and will have a checkbox to opt out of being on our list when a purchase is being made. When our customer submits their order and leaves the checkbox checked, I need to take that form submission and use the API to add that contact to our list.
I found this page: http://developer.constantcontact.com/doc/manageContacts#create_contact, but it just seems to have examples of XML, and doesn't explain what I need to know.
Can someone help get me on the right track? Thanks!
What you would need to do to get what you are looking for to work is to have the HTML form with a checkbox and field for email addresses. When that form is submitted, you will need a script, presumably PHP for you, to check to see if the box is checked, and then take the email address from the text box and put it into the XML format that is required for adding a contact. That format can be found here.
Once this is done, you would then do a POST on the Contacts Collection URI with the XML, and it will add the contact to our system.
We have some sample code that you can look at here to get you started. Also, if you have any specific questions please let me know and I can help you with your integration.
Hi Ben, and thanks for your reply!
I've got the scripting side down... mostly. I've downloaded the samples, and I'll review them. I don't understand how to "do a POST on the Contacts Collection URI with the XML". That sounds like something that is simple unless you don't know how to do it.
Once I get some answers from PHPurchase about what pages process the final checkout form, I will begin my integration and get back to you with other specific questions. If you can shed some light on "do a POST on the Contacts Collection URI with the XML", that would be the most helpful thing for me at this point.
You would want to do a HTTP post request to our Contacts URL. Our Contacts URL is https://api.constantcontact.com/ws/customers/USERNAME/contacts. You would need have your PHP create XML that is formatted in the correct form, which you can find in the link that I posted in the Contacts Collection URI.
If you are using PHP, you would then use cURL to make the http post, sending the XML to the contacts URL. If you have the XML correctly made, and send the http request to the correct URL, it will successfully add a contact.
If you take a look at the PHP sample code, it will give an example for doing this.