Create Campaign EmailTextContent does not correctly decode after receipt

Highlighted
Participant

Create Campaign EmailTextContent does not correctly decode after receipt

When sending our XML for creating a campaign we are encoding our EmailTextContent field per XML standards. & to & etc..  However, when previeiwing the text version of our email those encoded fields have not been decoded and thus links are being displayed - in a text only email - as


http://blahblah.com?test=1&test2=2


This causes issues with a variety of web sites that we are linking to.  Shouldn't the API decode the text field when it receives the data?


 

4 REPLIES 4
Highlighted
CTCT Employee

Re: Create Campaign EmailTextContent does not correctly decode

Hello,




Perhaps I'm misunderstanding what you're saying, but I was not able to replicate your issue as it seems to properly decoding any HTML characters I have tried, including the link you pasted directly in your post.


Could you respond to this post or send an email over to our webservices support team with the XML you are posting and running into this issue with, and I'd be happy to look into it further?


If you have any questions at all, please let us know. Thanks.

David J

Highlighted
Participant

I just checked - we are

I just checked - we are double encoding our ampersand's which is likely the issue here.  I will sort that out on our end verify.

Highlighted
Participant

We were not double encoding. 

We were not double encoding.  The issue is with the ctctwrapper.php file.  In the ctctwrapper.php file the Campaigns class has a createCampaignXML method. The method utilizes simplexml for building the xml. Calling simplexml->addChild() as needed to add child nodes. The addChild method requires your data/xml be encoded in order to add the node correctly.


However, after all the nodes have been added the createCampaignXML method generates a string of the XML via the asXML() method of the simplexml object.  A search and replace is then performed on the entire XML string. One of the patterns that is replaced is '&' which is replaced with &.  Thus resulting in double encoding of any & that already existed in any XML node.  I had a previous post that asked why those search and replaces were required. http://developer.constantcontact.com/node/1379


I simply added onto the search and replace patterns so that all double encoded patterns are replaced with single encoded ones. i.e. & to &


Seems like quite a hack and I didn't like manipulating the ctctwrapper.php file but I did not see any other option other than rewriting a large portion of the api library.


If someone else has better idea please let me know.

Highlighted
CTCT Employee

php wrapper

Hello,



I am going to look into this and see if we can do this a better way. I will post back here with any updates.



Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Developer Portal

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

Visit Page

Constant Contact Would Like To Hear From You!

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More
Featured