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
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?
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.
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. &amp; 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.
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.
View API documentation, code samples, get your API key.Visit Page
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