webservices

Obtaining a Campaign's Information

by Administrator on ‎03-25-2011 09:51 AM

You can obtain details of both template-based campaigns and custom-code campaigns.  For custom-code campaigns, you will get attributes of a campaign, such as subject, from email address, etc., as well as the actual content of the campaign, both HTML/XHTML and text.  For template-based campaigns, you will only get attributes of a campaign.

To obtain a campaign's information, call the following URI with GET method:

 

https://api.constantcontact.com/ws/customers/{user-name}/campaigns/{campaign-id}  

The GET on the campaign resource returns the details of a campaign as described in the Campaigns Collection Reference. The response body would return XML elements according to the Campaign Data Elements section of the Campaigns Collection Reference.  The details should include whether the campaign is based on templates or custom HTML/XHTML, whether the campaign is HTML or XHTML based if it's based on custom code, the campaign's status, details of the email itself, and settings on "View As Webpage" or "Permission Reminder" features.  In addition, the campaign detail includes the status and URL for the archived pages.

 

<CampaignType> signifies whether the campaign is based on templates (STOCK) or on custom HTML/XHTML code (CUSTOM).  If the campaign is template-based, then the XML would not contain <EmailContent>, <TextContent> and <StyleSheet> elements.

 

If the campaign is based on custom code, then the returned elements depend on whether the campaign is HTML or XHTML based, described by <EmailContentFormat> element, whose valid values are HTML and XHTML.  If the custom campaign is based on HTML, then the XML would contain only <EmailContent> and <TextContent><EmailContent> elements.  If the custom campaign is based on XHTML, then the XML would contain , <TextContent> and <StyleSheet>.

 

The email addresses used in <FromEmail> and <ReplyToEmail> are based on the email addresses of the account, which are represented through Account Setting email addresses collection and resource.  Please note that email addresses are represented as ID's and not actual email addresses.

 

The user's organization information is represented by <OrganizationName>, <OrganizationAddress1>, <OrganizationAddress2>, <OrganizationAddress3>, <OrganizationCity>, <OrganizationState>, <OrganizationInternationalState> and <OrganizationCountry> elements.  If you already entered organization information in your settings, or if you specified them when you created the campaign through the API, then these elements will return the organization information.  If they have not been set, they will not have any values.

 

If the campaign has been archived, you can also obtain the URL for the archived page through the campaign detail.  <ArchiveStatus> indicates whether the campaign has been archived, and <ArchiveURL> describes the URL for the archived page.  If the campaign has not been archived or the user does not have the archive functionality, both elements will be empty.

 

For template-based emails, you can obtain the URL for the 'Share Page'.  The Share Page is a hosted version of the sent email and it is used to support several social sharing features including 'Tweet this email'.  Use the <SharePageURL> element to access the address of this hosted page.