This would be a really BIG help. Still no coldfusion samples?
Thanks,
-BS
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>
<cfset ccUsername = "username">
<cfset ccPassword = "password">
<cfset apikey = "12345">
<!--- View Contacts --->
<cfhttp url="https://api.constantcontact.com/ws/customers/#ccUsername#/contacts" method="get" username="#apikey#%#ccUsername#" password="#ccPassword#">
</cfhttp>
<cfoutput>
<xmp>
#cfhttp.filecontent#
</xmp>
</cfoutput>
<!--- View Lists --->
<cfhttp url="https://api.constantcontact.com/ws/customers/#ccUsername#/lists" method="get" username="#apikey#%#ccUsername#" password="#ccPassword#">
</cfhttp>
<cfoutput>
<xmp>
#cfhttp.filecontent#
</xmp>
</cfoutput>
<!--- Update Contacts in Batch --->
<cfset ccData = "name,email
test one,one@test.com
test two,two@test.com">
<cfset ccLists = "http://api.constantcontact.com/ws/customers/#ccUsername#/lists/1">
<cfset ccBody = "activityType=SV_ADD&data=#URLEncodedFormat(ccData)#&lists=#URLEncodedFormat(ccLists)#">
<cfhttp url="https://api.constantcontact.com/ws/customers/#ccUsername#/activities" method="post" username="#apikey#%#ccUsername#" password="#ccPassword#">
<cfhttpparam type="header" name="Content-type" value="application/x-www-form-urlencoded" />
<cfhttpparam value="#ccBody#" type="body" />
</cfhttp>
<cfoutput>
#cfhttp.filecontent#<br><br>
</cfoutput>
</code>
Thanks so much. That is a big help!!
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.
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.
David J
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 < to < and all of the > to >
Is it possible I need to convert other text as well?
Thanks!
John
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
Contacts.getContacts() should be returning a multidimensional array of up to 50 contact objects, and a link to the next page of 50 if one exists. You should not be seeing XML at all. Would you be able to either post the code you are using here, or email your code (and username/password if you want me to test your specific account) to our webservices support team so that I can take
David J