Reply
Occasional Advisor
ZoomTan
Posts: 13
Registered: ‎05-04-2010
Accepted Solution

Updating/Copying Campaign

Hi,

 

I am having issues copying or updating a campaign with the php wrapper class.

 

For copying, I search through the campaigns via the wrapper class and find the correct one. I then assign the new name to the object and pass it to the ContactsCollection class createCampaign function. I always receive a 400 error. I am also trying to update campaigns in draft mode with new names but nothing seems to work. I do this the same way as describe above. Ultimately what I want to do is to be able to make a copy of a draft campaign that our web designer creates, and then schedule it via this wrapper class. Can someone please help?

 

Thanks

CTCT Employee
bsoder
Posts: 440
Registered: ‎06-05-2009

Re: Updating/Copying Campaign

Hello,

 

I tried recreating the issue you were having on my end and I was not able to reproduce it in the wrapper.  Is it possible for you to send your code here so I can take a look at it and see if I can spot what is going on.

 

If you have any questions please let me know.

Benjamin Soder
NOC Analyst
Constant Contact
Occasional Advisor
ZoomTan
Posts: 13
Registered: ‎05-04-2010

Re: Updating/Copying Campaign

Dear Benjamin, I have emailed you the code sample. Any help you could provide would be great. Thanks a lot.

Occasional Advisor
ZoomTan
Posts: 13
Registered: ‎05-04-2010

Re: Updating/Copying Campaign

[ Edited ]

Benjamin here is the xml I am using. I replaced my username with "UserName" and substituded personal info but everything else is as it's sending

 

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
      <link href="/ws/customers/UserName/campaigns" rel="edit"/>
      <id>http://api.constantcontact.com/ws/customers/UserName/campaigns</id>
      <title type="text">test2</title>
      <updated>2011-06-06T12:10:12+01:00</updated>
      <author>
            <name>Constant Contact</name>
      </author>
      <content type="application/vnd.ctct+xml">
            <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/UserName/campaigns/1100546096289">
                  <Name>test2</Name>
                  <Status>draft</Status>
                  <Date>2011-06-07T12:10:12+01:00</Date>
                  <Subject>Test Email</Subject>
                  <FromName>Company, LLC</FromName>
                  <ViewAsWebpage>YES</ViewAsWebpage>
                  <ViewAsWebpageLinkText></ViewAsWebpageLinkText>
                  <ViewAsWebpageText></ViewAsWebpageText>
                  <PermissionReminder>NO</PermissionReminder>
                  <PermissionReminderText></PermissionReminderText>
                  <GreetingSalutation>Dear</GreetingSalutation>
                  <GreetingName>FirstName</GreetingName>
                  <GreetingString>Greetings!</GreetingString>
                  <OrganizationName>Company Name</OrganizationName>
                  <OrganizationAddress1>Company Address</OrganizationAddress1>
                  <OrganizationAddress2></OrganizationAddress2>
                  <OrganizationAddress3></OrganizationAddress3>
                  <OrganizationCity>Company City</OrganizationCity>
                  <OrganizationState>Company State</OrganizationState>
                  <OrganizationInternationalState></OrganizationInternationalState>
                  <OrganizationCountry>us</OrganizationCountry>
                  <OrganizationPostalCode>Company Zip</OrganizationPostalCode>
                  <IncludeForwardEmail>NO</IncludeForwardEmail>
                  <ForwardEmailLinkText>Forward email</ForwardEmailLinkText>
                  <IncludeSubscribeLink>NO</IncludeSubscribeLink>
                  <SubscribeLinkText>Subscribe me!</SubscribeLinkText>
                  <EmailContentFormat>HTML</EmailContentFormat>
                  <EmailContent>
                        <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:cctd="http://www.constantcontact.com/cctd">
                              <body>
                                    <CopyRight>Copyright (c) 1996-2011 Constant Contact. All rights reserved. Except as permitted under a separatewritten agreement with Constant Contact, neither the Constant Contact software, nor any content that appears on any Constant Contact site,including but not limited to, web pages, newsletters, or templates may be reproduced, republished, repurposed, or distributed without theprior written permission of Constant Contact. For inquiries regarding reproduction or distribution of any Constant Contact material, pleasecontact legal@constantcontact.com.</CopyRight>
                                    <OpenTracking/>
                                    <!-- Do NOT delete previous line if you want to get statistics on the number of opened emails -->
                                    <CustomBlock name="letter.intro" title="Personalization">
                                          <Greeting/>
                                    </CustomBlock>
                              Hi there!</body>
                        </html>
                  </EmailContent>
                  <EmailTextContent>
                        <Text>
                              <Greeting/>
                        Hi there!</Text>
                  </EmailTextContent>
                  <StyleSheet></StyleSheet>
                  <ContactLists>
                        <ContactList id="http://api.constantcontact.com/ws/customers/UserName/lists/59">
                              <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/UserName/lists/59" rel="self"/>
                        </ContactList>
                  </ContactLists>
                  <FromEmail>
                        <Email id="http://api.constantcontact.com/ws/customers/UserName/settings/emailaddresses/2">
                              <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/UserName/settings/emailaddresses/2" rel="self"/>
                        </Email>
                        <EmailAddress>me@me.com</EmailAddress>
                  </FromEmail>
                  <ReplyToEmail>
                        <Email id="http://api.constantcontact.com/ws/customers/UserName/settings/emailaddresses/2">
                              <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/UserName/settings/emailaddresses/2" rel="self"/>
                        </Email>
                        <EmailAddress>me@me.com</EmailAddress>
                  </ReplyToEmail>
            </Campaign>
      </content>
      <source>
            <id>http://api.constantcontact.com/ws/customers/UserName/campaigns</id>
            <title type="text">Campaigns for customer: UserName</title>
            <link href="campaigns"/>
            <link href="campaigns" rel="self"/>
            <author>
                  <name>UserName</name>
            </author>
            <updated>2011-06-06T12:10:12</updated>
      </source>
</entry>

CTCT Employee
bsoder
Posts: 440
Registered: ‎06-05-2009

Re: Updating/Copying Campaign

Hello,

 

I tested out your XML and I believe the problem is, is that you are not HTML encoding your EmailContent and EmailTextContent nodes.  Once I did this it did post successfully.  All HTML tags must be HTML encoded (with at least either the greater than or less than sign on each tag encoded).

 

Let me know if this works.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Occasional Advisor
ZoomTan
Posts: 13
Registered: ‎05-04-2010

Re: Updating/Copying Campaign

Benjamin, I don't see exactly where the html content is not encoded properly. Also I pulled the html content from ctct using the API (I created the test campaigin and custom email using your web interface). Could you give me a little more detail as to exactly what isn't encoded properly/what you did?

 

Thanks.

CTCT Employee
bsoder
Posts: 440
Registered: ‎06-05-2009

Re: Updating/Copying Campaign

Hello,

 

I apologize for the confusion.  So instead of the EmailContent node being passed like this:

 

<html>
  <body>
    <div>test</div>
  </body>
</html>


You would want to have it passed like this:

&lt;html>
  &lt;body>
    &lt;div>test&lt;/div>
  &lt;/body>
&lt;/html>

Once I did this, it posted successfully.  Please let me know if you have any questions.

Regards,
Benjamin Soder
NOC Analyst
Constant Contact
Occasional Advisor
ZoomTan
Posts: 13
Registered: ‎05-04-2010

Re: Updating/Copying Campaign

[ Edited ]

Benjamin, I am using the following XML and I am still receiving 400. I have also used full html encoding (which means double quotes are &quot with no success)

 

<entry xmlns="http://www.w3.org/2005/Atom">
    <link href="/ws/customers/UserName/campaigns" rel="edit"/>
    <id>http://api.constantcontact.com/ws/customers/UserName/campaigns</id>

    <title type="text">test2</title>
    <updated>2011-06-07T10:44:26+05:00</updated>
    <author>
        <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
    <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/UserName/campaigns/1100546096289">

      <Name>test2</Name>
      <Status>draft</Status>
      <Date>2011-06-07T10:44:26+05:00</Date>
      <Subject>Test Email</Subject>
      <FromName>Company, LLC</FromName>
      <ViewAsWebpage>YES</ViewAsWebpage>

      <ViewAsWebpageLinkText></ViewAsWebpageLinkText>
      <ViewAsWebpageText></ViewAsWebpageText>
      <PermissionReminder>NO</PermissionReminder>
      <PermissionReminderText></PermissionReminderText>
      <GreetingSalutation>Dear</GreetingSalutation>
      <GreetingName>FirstName</GreetingName>
      <GreetingString>Greetings!</GreetingString>

      <OrganizationName>Zoom Tan, LLC</OrganizationName>
      <OrganizationAddress1>9999 Street Avenue #4</OrganizationAddress1>
      <OrganizationAddress2></OrganizationAddress2>
      <OrganizationAddress3></OrganizationAddress3>
      <OrganizationCity>City</OrganizationCity>
      <OrganizationState>State</OrganizationState>
      <OrganizationInternationalState></OrganizationInternationalState>

      <OrganizationCountry>us</OrganizationCountry>
      <OrganizationPostalCode>00000</OrganizationPostalCode>
      <IncludeForwardEmail>NO</IncludeForwardEmail>
      <ForwardEmailLinkText>Forward email</ForwardEmailLinkText>
      <IncludeSubscribeLink>NO</IncludeSubscribeLink>
      <SubscribeLinkText>Subscribe me!</SubscribeLinkText>

      <EmailContentFormat>HTML</EmailContentFormat>
      <EmailContent>&lt;html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:cctd="http://www.constantcontact.com/cctd"&gt;



&lt;body&gt;&lt;CopyRight&gt;Copyright (c) 1996-2011 Constant Contact. All rights reserved.  Except as permitted under a separate
written agreement with Constant Contact, neither the Constant Contact software, nor any content that appears on any Constant Contact site,
including but not limited to, web pages, newsletters, or templates may be reproduced, republished, repurposed, or distributed without the
prior written permission of Constant Contact.  For inquiries regarding reproduction or distribution of any Constant Contact material, please
contact legal@constantcontact.com.&lt;/CopyRight&gt;
&lt;OpenTracking/&gt;
&lt;!--  Do NOT delete previous line if you want to get statistics on the number of opened emails --&gt;


&lt;CustomBlock name="letter.intro" title="Personalization"&gt;
    &lt;Greeting/&gt;
&lt;/CustomBlock&gt;


Hi there!


&lt;/body&gt;
&lt;/html&gt;</EmailContent>
      <EmailTextContent>&lt;Text&gt;&lt;Greeting/&gt; Hi there!&lt;/Text&gt;</EmailTextContent>

      <StyleSheet></StyleSheet>
      <ContactLists>
          <ContactList id="http://api.constantcontact.com/ws/customers/UserName/lists/59">
    <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/UserName/lists/59" rel="self"/>
</ContactList>
      </ContactLists>
      <FromEmail>
          <Email id="http://api.constantcontact.com/ws/customers/UserName/settings/emailaddresses/2">
          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/UserName/settings/emailaddresses/2" rel="self"/>

           </Email>
          <EmailAddress>me@me.com</EmailAddress>
      </FromEmail>
      <ReplyToEmail>
       <Email id="http://api.constantcontact.com/ws/customers/UserName/settings/emailaddresses/2">
          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/UserName/settings/emailaddresses/2" rel="self"/>
           </Email>
          <EmailAddress>me@me.com</EmailAddress>

      </ReplyToEmail>
    </Campaign>
  </content>
  <source>
    <id>http://api.constantcontact.com/ws/customers/UserName/campaigns</id>
    <title type="text">Campaigns for customer: UserName</title>
    <link href="campaigns"/>
    <link href="campaigns" rel="self"/>

    <author>
      <name>UserName</name>
    </author>
    <updated>2011-06-07T10:44:26+05:00</updated>
  </source>
</entry>

DaveBerard
Posts: 1,632
Topics: 7
Kudos: 61
Solutions: 57
Registered: ‎06-19-2008

Re: Updating/Copying Campaign

That should clear up any errors you were receiving regarding content format, however you still have an invalid node value (which the full error message from the library should provide you).  You are setting ViewAsWebpage to YES but are not providing the required text fields:

 

      <ViewAsWebpage>YES</ViewAsWebpage>
      <ViewAsWebpageLinkText></ViewAsWebpageLinkText>
      <ViewAsWebpageText></ViewAsWebpageText>

 

This should, correctly, through a 400 error telling you that ViewAsWebpageLinkText and ViewAsWebpageText cannot be blank. 

Dave Berard
Senior Product Manager, Constant Contact
Occasional Advisor
ZoomTan
Posts: 13
Registered: ‎05-04-2010

Re: Updating/Copying Campaign

[ Edited ]

That did the trick Dave thanks so much! I did notice something else though. When I set for vawp and I include vawptext and link text in the actual campaign creation on the web interface, I am able to retrieve the showvawp but neither of the text fields. All other information is returned though. Weird