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?
Hey,
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"); ?><table><?php do { foreach($SentCampaigns['campaigns'] as $Campaign) { $myCampaign = $ConstantContact->getCampaigndetails($Campaign); if($myCampaign->archiveStatus == "Published") { ?> <table> <tr> <td> <?php echo $myCampaign->name; ?> </td> <td> <?php echo $myCampaign->archiveUrl; ?> </td> </tr> <?php } } if($ConstantContact->getCampaignsByStatus("Sent", $SentCampaigns['nextLink']) != FALSE) { $NextSet = $ConstantContact->getCampaignsByStatus("Sent", $SentCampaigns['nextLink']); $SentCampaigns = $NextSet; } }while($SentCampaigns['nextLink']!= false); ?></table>
Please let me know if this helps.
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.
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:
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
can anybody show me an example of this in Javascript?
can this be done in javascript?
Hello,
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!
Sincerely,
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?
this code does not look like its complete, do I need a url link to the api?