We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

help listing email archive links using API


help listing email archive links using API

I'm trying to avoid the manual process of adding campaigns that have been archived to an html page, and would rather generate a simple list of those campaigns that HAVE been archived.


I'm using the API to return a list of all SENT campaigns, then one by one checking for Archive status of Published, and if so, listing the Archive URL on the page.

This takes a very long time to load, even though it's only cycling through the first 50 emails. (of course, this is also problematic if we have archives that are older than the first 50 sent campaigns)

Is there any way to create that list automatically without cycling through every email sent out?




If you are using our new PHP wrapper you can do something like this to get you started.


$ConstantContact = new ConstantContact("basic", "apikey", "username", "password");

$SentCampaigns = $ConstantContact->getCampaignsByStatus("Sent");

do {
	foreach($SentCampaigns['campaigns'] as $Campaign)
		$myCampaign = $ConstantContact->getCampaigndetails($Campaign);
		if($myCampaign->archiveStatus == "Published")
			<?php echo $myCampaign->name; ?>
			<?php echo $myCampaign->archiveUrl; ?>
	if($ConstantContact->getCampaignsByStatus("Sent", $SentCampaigns['nextLink']) != FALSE)
		$NextSet = $ConstantContact->getCampaignsByStatus("Sent", $SentCampaigns['nextLink']);
		$SentCampaigns = $NextSet;
}while($SentCampaigns['nextLink']!= false);


 Please let me know if this helps.

Ryan Davis
Quality Engineer

Ryan, That's almost exactly the code I am using - but I'm getting a 502 proxy error or timeout. I'm assuming the issue is with looping through getCampaignDetails too many times. Any suggestions?

Are any of the requests going through or are all of them returning 502/timeout?  Also, can you provide us with the full error message being returned by us?  Our limits to API access are quite high and there isn't enough campaign content in your account for you to hit those limits even if you attempted to cycle through and pull all the campaigns.

Dave Berard
Senior Product Manager, Constant Contact

I sent you a PM with the code and link to the page it's on. Thank you!

Thanks for providing the URL and code.  This error message we're seeing is not usually related to actual PHP code or a server error but to an Apache Proxy server configuration error.  You'll notice that the error is being returned to a file on your server and not through something on Constant Contact side of the connection.  Also, the detailed error explains a lot into the underlying cause:


Proxy Error

The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /enews/cc/campaign_archive.php/.

Reason: Error reading from remote server


Apache/2.2 Server at www.east91st.org Port 80
While I am not an expert on Apache or server configurations, this is likely caused by either the PHP script taking too long to run and running past the Apache server time out, thus causing an error since the upstream server could not send a response or there is a configuration issue in the proxy configuration you're using in Apache.  I've seen a few Apache forum posts saying that there is a known problem with versions of httpd prior to 2.2.4 causing these errors when proxy settings are included and also mentions of several people solving this problem by adjusting the timeout settings to a longer timeout wait.  If the script itself takes too long to run, which is possibly if you're looking at a large number of campaigns and making a large number of serial requests instead of parallel requests, this is likely the root cause.
We're going to run your code locally today to ensure that it does work and will post additional information later today to confirm that the code is indeed correct.
Dave Berard
Senior Product Manager, Constant Contact
Occasional Participant

can anybody show me an example of this in Javascript?


Occasional Participant

can this be done in javascript?



At present it is not possible to integrate with the Constant Contact API in pure javascript. This is because ou API is not compatible with JSONP(Which only supports GET requests) and does not currently support CORS. Given this, the only way to use javascript without being blocked by XSS restrictions is to have a mechanism to forward your requests through a back-end script running on the same host. 


Please let me knwo if you have any questions!



Elijah G.
API Support Engineer
Regular Participant

I am building a PhoneGap app thats why i need it in jQuery / javascript


I guess I'll have to use wordpress to display the archive, do you have a more complete code that i can use in wordpress?

Regular Participant

this code does not look like its complete, do I need a url link to the api?

Developer Portal

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

Visit Page