Create Mass Contacts

SOLVED
Go to solution
Regular Participant

Create Mass Contacts

 I am trying to add multiple contacts to a contact list from my web application to your api.  I went to look at the document section on how to do this but I can't seem to wrap my head around it.  Can you send me some examples on how to write up this code for coldfusion


 


Thanks


Chris

1 ACCEPTED SOLUTION

The error you are seeing is indicating that the including .cfc file could not be loaded at runtime.  This usually indicates that the file path for the .cfc could not be found.  Here is a post about a common cause of this: http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/solve-the-could-not-find-the-coldf...

 

I've researched what you're seeing and most reports of this are caused by either the .cfc file being included too many times or the path not being resolved.  The base code itself does work in both ColdFusion wrappers and is in use by multiple integrations at this point.  Can you post additional information about which version of the wrapper you're using and, if you are using anything, any frameworks that are also installed?

Dave Berard
Senior Product Manager, Constant Contact

View solution in original post

10 REPLIES 10
Employee

Hi Chris,


 


I do have some examples of this in ColdFusion 8 and 9 that are hosted at http://sourceforge.net/projects/ctctcfwrapper/. If you are looking to do a specific Bulk Add/Remove Contacts Activity, I'd be happy to go into further details on this.

David J

Regular Participant

 yes, I would like to do a bulk add/remove contacts activity.  Can you help me out with that

Employee

There are two different types of bulk add/remove contact activities, application/x-www-urlencoded or multipart/form-data. These are different types of requests and would need to be setup slightly different, but I do have samples of both of them in the link I gave you. It would really depend on how you have your data stored at the moment as to which you would probably want to use. If you could give me a little context information on how your data is stored and the goal of what you're looking to do, I can likely help you decide which one to use and give you some examples of that.

David J

Regular Participant

 Sure thing David!


 


I have a database of prospect emails that I would like to send over to constant contact.  On my web application, the user selects a list of emails, either chooses to create a new contact list or an existing one and an email campaign.  Then the system goes through a cross check system from my list to constant contact.  If the contact is new add them to the list, if they exist and have a do not mail status do not add them.  


After the cross check has finished, the emails are then sent to my constant contact account via bulk add.  


Hopefully this makes sense on what i'm trying to accomplish.


 

Employee

Just so that I am clear, it sounds like you're doing a bunch of processing with the contacts to figure out who needs to be created and who does not. Once you've finished processing that information you are looking to add all the necessary contacts to Constant Contact in one bulk job.


If this is correct, I think your best bet is going to be to make an application/x-www-form-urlencoded add contacts activity. I do have some CF8 and CF9 examples of this, they may need to be slightly modified to work in BlueDragon, but I would imagine that the CF8 version would need very few if any modifications.


You would just need to programmatically create a URL encoded string the fits the format found on Creating an application/x-www-form-urlencoded Add/Remove Contacts Activity. Below would be a ColdFusion implementation of the example on the page I just linked you.


<cfset ActivitiesCollection = createObject("component", "ActivitiesCollection").init()>



<cfset uploadString = "activityType=SV_ADD&data=Email+Address%2CFirst+Name%2CLast+Name%0A

wstest3%40example.com%2C+Fred%2C+Test%0A

wstest4%40example.com%2C+Joan%2C+Test%0A

wstest5%40example.com%2C+Ann%2C+Test

&lists=http%3A%2F%2Fapi.constantcontact.com%2Fws%2Fcustomers%2Fjoesflowers%2Flists%2F18">




<cfset bulkActivity = ActivitiesCollection.bulkUrlEncoded(uploadString)>

 


I hope this helps. If you have any questions regarding this please let me know and I'll be happy to help.

David J

Occasional Participant

Hi there,

 

I'm trying to do a similar thing. I've got a bunch of contacts on my own database and I want to attach them all to a list (I already know the list ID).

 

I've looked at your code example above and this seems to envisage using a component called ActivitiesCollection

 

If I just try and run your code above (<cfset ActivitiesCollection = createObject.....)  it fails with the message:-

"Could not find the Coldfusion component or interface utility"

 

I've previously downloaded the CTCTwrapper files, so I had a look through them. Within those I did find an ActivitiesCollection.cfc file. However the syntax of that file doesn't match the syntax of the other files that I've got working from your CF sample files (e.g. Lists.cfc and Contacts.cfc)

 

I tried enclose the code in the ActivitiesCollection.cfc file with <cfscript> tags and that seemed to bring the code to life (within dreamweaver) which seemed to imply that was what it needed. However when I try and run my test page (within the same directory) I'm getting the same error as before. I've tried cfincluding the ActivitiesCollection.cfc file within my test file but that doesn't seem to help

 

I can see that it would be possible to rewrite the whole of the ActivitiesCollection.cfc file putting it into the samy syntax as the other files that work (e.g. starting out with a <cffcomponent> and containing vairous <cffunctions>) but this is a lot to do on the back of a hunch. 

 

Is there somethign simple I need to do to the contents of the ActivitiesCollection.cfc file to make it recognised by my test page?

 

Pleaes let me know

 

Thanks

 

Mark 

The error you are seeing is indicating that the including .cfc file could not be loaded at runtime.  This usually indicates that the file path for the .cfc could not be found.  Here is a post about a common cause of this: http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/solve-the-could-not-find-the-coldf...

 

I've researched what you're seeing and most reports of this are caused by either the .cfc file being included too many times or the path not being resolved.  The base code itself does work in both ColdFusion wrappers and is in use by multiple integrations at this point.  Can you post additional information about which version of the wrapper you're using and, if you are using anything, any frameworks that are also installed?

Dave Berard
Senior Product Manager, Constant Contact

View solution in original post

Thanks for the prompt response - that article looks like it gives me a few things to try - I've got Application.cfc in the same directory as my page - I'll try tweaking that and telling it where the file is

Thanks to your help it has moved on - I copied the ctwrapper files into the working directory and things started to happen. 

 

I'm still having problems though and wonder if you could help

 

The order of what I'm trying to do is as follows:-

On my own webpages the users chooses who to mail shot from a list they are presented with - they select or deselect each relevant address name

They then give the new list a name

 

It then uses ajax to call a cfc file.

 

- This firstly creates the list

- then it grabs the list ID by checking the list name against the available lists

- Then it does a bulk update adding that list ID to each of the contacts that were selected.

 

Earlier I had the problems that when I got above a certain number of lists it didn't seem to want to let me find that list name any more. I deleted 20 or so test lists and it was then working OK. 

 

To create a list I'm using:-

 

 <cfset NEWLISTDATA="<entry xmlns='http://www.w3.org/2005/Atom'><id>data:,</id><title /><author /><updated>" & #mydate# & "</updated><content type='application/vnd.ctct+xml'><ContactList xmlns='http://ws.constantcontact.com/ns/1.0/'><OptInDefault>false</OptInDefault><Name>" & #arguments.list_name# & "</Name><SortOrder>88</SortOrder></ContactList></content></entry>">
 <cfset httpResponse = createObject("component", "Lists").addList(#NEWLISTDATA#)>

 

That seems to work OK each time

 

To grab the list ID I'm doing the following:-

<cfset allLists = createObject("component", "Lists").getLists()>

<cfset NEWLISTID="UNDEFINED">

<cfloop from="1" to="#arrayLen(allLists)#" index="i">

<cfset contactLists = StructNew()>           

<cfif allLists[i][1] EQ #arguments.list_name#>

<cfset NEWLISTID= allLists[i][2]>

</cfif>

</cfloop>

 

This is now working but while I had over 50 lists it was seeing the list name as 'UNDEFINED' each time.

 

Since I've deleted those 20 or so test ones it seems to work now - but is the a limit to the number lists that I can use? Or is it connected with me assigning a statis SortOrder each time?

 

One last point - On my last test it seemed to cerate the list straight away, but with apparently no members. Then about a minute after the members appeared but when I went to look at them they apparently weren't there (it said 12 members but wouldn't list them). Now I've gone back after 5 minutes and they are all there. Is this a normal sort of time lag? -if I know then I can warn the user to go and have a cup of tea before moving to the next stage

 

Thanks for your help

 

Cheers

 

Mark

 

 

 

 

 

 

 

 

 

 

 

 

 

 

We do not have any limit to the number of lists allowed in an account.  For pratical reasons, I.E. customer ability to manage large numbers, most of our customers keep the numbers under 100 lists.  Reusing lists to update with new members or update membership is the most common way to keep list totals to a reasonable number.  That said, we have customers who are in the high hundreds of lists and some integrated developers who I've seen well in the 1000s.

 

Regarding the lag time you're seeing, this is the expected behavior of the Bulk Activity API.  This is a batch processing API that works off queueing up large jobs in our system in a FIFO system and processing the jobs as the server is able to.  Typical response time is usually under 10 minutes, though for large imports (10k+) the total processing time may be 10-20 minutes to get all the updates and creations through. 

 

Since it's an asyncronous batch, we expose the status of the imports as part of the Activity.  When first created, for example, the status will be "QUEUED" since it is in the QUEUE.  Once it's about to be processed, it will be moved to the "PENDING" state, which means it's been assigned to one of our import jobs and is waiting to be processed.  Once it's complete, it will have the status changed to "COMPLETED". 

 

You can find out more about this API here: http://community.constantcontact.com/t5/Documentation/Bulk-Activity-Collection-of-Activities/ba-p/25...

 

Note: the wrapper library you have should have the ability to query and get the status of specific jobs via the XML returned when creating the Activity and then using the proper method for getting the status of that Activity.  This can be used to provide feedback to the user on the current status and an option for refreshing the status either manually or through a timed feature that auto-refreshes the status.

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page