Between 8:00 - 9:00 am ET on 10/25 we need to take our site down to make updates. We recommend logging out before 8:00am ET and not using your account during this time. Thank you for your patience while we make these important updates.

Create campaign script doesn't work correctly

Regular Participant

Create campaign script doesn't work correctly

Hi.

 

I've installed the php-sdk-master on my local server and tried to create campaign using the example script.

 

I set up the AppKey and AccessToken vars and applied

http://www.tfabenefits.com/cc_dev/php-sdk-master/examples/template_dev2.html template

 

The campaign was successfully created. Although, I was getting this annoying error - Field does not support script content.

I got rid of the css causing this error and the template successfully applied.

 

But then I uploaded this php-sdk-master script on the server for testing the same functionality

 

http://www.tfabenefits.com/cc_dev/php-sdk-master/examples/createAndScheduleCampaign.php

 

and couldn't create campaign using mentoned template.

 

Every time I get this error - Field does not support script content.

 

Can you help me to resolve this issue? Is there a possibility that the server (not local server) is somehow causing the error?

 

I tried to apply very simple template like,

<html>

<body>

<div style="color: #000000; float: left;">test</div>

</body>

</html>

 

and even such simple template didn't apply.

 

Thanks.

 

 

6 REPLIES 6
Regular Participant

Hi.

 

Has any of the moderators read this post?

 

I didn't ask to fix this problem for me.

 

Just to check my template and the script I mentioned in the first post.

 

The problem is that I can successfully upload my template via createAndScheduleCampaign.php on my local server, but when I uploaded this script on my other server, the template doen't work. I always get this error - Field does not support script content.

 

How is that ever possible? The template is valid because I can apply it using the createAndScheduleCampaign.php script on my local server.

 

Thanks.

Have you tried doing a dump of the campaign object you are trying to create in your production server?  I agree, it fundamentally makes no sense that you would get two different responses in two different environments if everything is identical.  This leads me to believe that something is different in the request being made, which is highly likely to be related to a difference in your environments. 

 

Have you looked at your PHP error log or warning log in your production server to see if there is something failing silently?  Often times the settings on a production server surpress php warnings and errors or send it to a log file which can make troubleshooting challening.  Without the details of what you're sending in the two different environments, it will be fairly hard to give any guidance though. 

 

Dave Berard
Senior Product Manager, Constant Contact
Regular Participant

Hi DaveBerard.

 

Thank you for your quick replya and the clues.

 

Here is what I found.

 

I used var_dump for this:

 

var_dump($campaign->email_content);

 

And in the source code I found that on my server the whole html template content is escaped (sort of using addslashes).

 

Here is the extract:

 <body style=\"background: url(\'http://www.tfabenefits.com/wp-content/themes/tfa/images/body-bg.jpg\') repeat-x scroll 0 0;background-color: #E3E3E2; font-family: \'Ubuntu Condensed\',sans-serif; font-size: 100%; font-weight: 400; margin: 0 0 0 0;\"><div style=\"margin: 0 auto; overflow: hidden; width: 980px;\">

And on my local server the template is not using any escape function (it's as is) no backslashes.

 

Is it supposed to be escaped?

 

Thank you for your help.

The content should be escaped automatically when the object is converted to JSON, so in the case of your production server it will be double escaped causing us to fail parsing on our side when we decode the JSON.  Very strange that it's getting escaped twice, is it the exact same code on both environments?  Are you storing the HTML somewhere and retrieving it and potentially encoding it along the way?

Dave Berard
Senior Product Manager, Constant Contact
Member

Hello,

 

Thanks for posting.  Taking a look at the page you referenced, there are two occurrences of a common culprit that gets blocked by the filter.  The filter blocks style "background: url( ...)".  Change those and you should be able to create a campaign with that content.  Hope the information helps.

 

Andrew B.

Constant Contact

API Support

 

Regular Participant

Hi AndrewB776.

Thank you for your quick reply.

 

As I mentioned before I can apply my template on my local server, so I don't think that background: url(...) is restricted by the filter. If the filter really blocks this css property than it doesn't work correctly at least for my template. It doesn't return the script error.

Developer Portal

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

Visit Page