Basic adding/subtracting single contacts with Coldfusion?

Highlighted
New Member

Basic adding/subtracting single contacts with Coldfusion?

I have been hired to work on a Coldfusion website and one of the "bonus" features they would like to have added is the adding of an e-mail address and first/last name directly to their Constant Contact account upon registration or removed in the online profile. Are there any examples of this implementation located here anywhere.

Any help is much appreciated.

Thank you!
11 REPLIES 11
Moderator

We currently do not have any

We currently do not have any examples of Coldfusion provided by Constant Contact. It may be possible another developer has already done this before though and can provide you with some examples.
Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Participant

Basic adding/subtracting single contacts with Coldfusion? Reply

We're looking for the same thing too....
Highlighted
Occasional Participant

still nothing?

This would be a really BIG help. Still no coldfusion samples?


Thanks,


-BS

Highlighted
New Member

adding bulk contacts with coldfusion

Wow. This took me the better part of a day, but I finally figured out how to view contacts, view lists and bulk add contacts with Coldfusion.  Here's my very simple and "testing" code. It should get you started. Let me know if you have questions.


-Mark


<code>


&lt;cfset ccUsername = "username"&gt;

&lt;cfset ccPassword = "password"&gt;

&lt;cfset apikey = "12345"&gt;



&lt;!--- View Contacts ---&gt;

&lt;cfhttp url="https://api.constantcontact.com/ws/customers/#ccUsername#/contacts" method="get" username="#apikey#%#ccUsername#" password="#ccPassword#"&gt;

&lt;/cfhttp&gt;



&lt;cfoutput&gt;

&lt;xmp&gt;

#cfhttp.filecontent#

&lt;/xmp&gt;

&lt;/cfoutput&gt;



&lt;!--- View Lists ---&gt;

&lt;cfhttp url="https://api.constantcontact.com/ws/customers/#ccUsername#/lists" method="get" username="#apikey#%#ccUsername#" password="#ccPassword#"&gt;

&lt;/cfhttp&gt;



&lt;cfoutput&gt;

&lt;xmp&gt;

#cfhttp.filecontent#

&lt;/xmp&gt;

&lt;/cfoutput&gt;





&lt;!--- Update Contacts in Batch ---&gt;

&lt;cfset ccData = "name,email

test one,one@test.com

test two,two@test.com"&gt;

&lt;cfset ccLists = "http://api.constantcontact.com/ws/customers/#ccUsername#/lists/1"&gt;



&lt;cfset ccBody = "activityType=SV_ADD&data=#URLEncodedFormat(ccData)#&lists=#URLEncodedFormat(ccLists)#"&gt;



&lt;cfhttp url="https://api.constantcontact.com/ws/customers/#ccUsername#/activities" method="post" username="#apikey#%#ccUsername#" password="#ccPassword#"&gt;

    &lt;cfhttpparam type="header" name="Content-type" value="application/x-www-form-urlencoded" /&gt;

    &lt;cfhttpparam value="#ccBody#" type="body" /&gt;

&lt;/cfhttp&gt;



&lt;cfoutput&gt;

#cfhttp.filecontent#&lt;br&gt;&lt;br&gt;

&lt;/cfoutput&gt;



</code>

Highlighted
Occasional Participant

Thanks

Thanks so much. That is a big help!!

Highlighted
New Member

works like a charm

I downloaded the ColdFusion examples from CC but they do not work out of the box.


I gave up on fixing them and tried Google search, and found this. Just what I need - excellent!


Thanks a lot!


 


p.p. One suggestion to CC. Please, post some simple examples like the one above - few lines and excelent results, not tons of code. Very simple so even if our server environment is different they still work.


The examples that you have, don't work here and the error is 401 Basic Auth Failed, despite the fact that I am providing all my credential in a proper manner.

Highlighted
CTCT Employee

Re: works like a charm

I have not received reports from anyone else that any of the ColdFusion samples are broken right out of the box, or that people receive 401 Authentication errors, provided that you are running ColdFusion9.  If you could provide some more information as to exactly what was not working, I'd be more than happy to take a look at them. The only thing that should need to be configured would be setting up the username, password and apikey in Application.cfc.


 


For example, in the ColdFusion library you would setup the username, password, and apikey in Application.cfc. Then you could make a 'development.cfm' (or any .cfm page) and use the following to display the first page of contacts.


<cfset contacts = new ContactsCollection().getContacts()>



<cfdump var="#contacts#">

David J

Highlighted
Occasional Participant

Invalid xml declaration.

This looks like a great solution but I am receiving this error:



Invalid xml declaration.

 Line: 3 Character: 3


<?xml version="1.0" encoding="UTF-8"?>



I converted all of the &lt; to < and all of the &gt; to >


Is it possible I need to convert other text as well?


Thanks!


John

Highlighted
Occasional Participant

Invalid xml declaration (cont)

For me this cf code returned a blank page with the error I mentioned above.  So I looked at the source for my "blank" page and discovered the xml for all my contacts.  So the cf code seems to be correctly connecting to my account but is the cf supposed to parse this xml, or is the xml supposed to display in the browser?


Also, why is it saying that "<?xml version="1.0" encoding="UTF-8"?>" is an invalid xml declaration?


Thanks for reading this!


John

Developer Portal

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