The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Integration with WordPress and PHPurchase

Highlighted
New Member

Integration with WordPress and PHPurchase

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!

3 REPLIES 3
Highlighted
Employee

sign up form

Hello,



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.



Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Highlighted
New Member

thanks... a little more detail?

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.


Cheers!


Andrew

Highlighted
Employee

creating a signup form

 Hello,



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.



Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured