Just wanted to post this in case it helps someone. I've noticed before that although Campaign Monitor's API appears to work in UTF-8, that UTF-8 character strings don't make it through correctly when using the provided PHP wrapper. I have a Danish client who needed this to work for obvious reasons, so I finally dug in and found the problem.
Turns out that the PHP wrapper assumes that the strings you feed it are not already UTF-8, and it runs everything through utf8_encode(), and trying to encode a string that's already UTF-8 produces gibberish. If you're working with Wordpress (as I often do), you'll run into this problem as the WP folks were smart enough to use UTF-8 as its charset.
The fix is easy, just remove the offending utf8_encode call in line 176 of CMBase.php:
$postdata .= '&' . $k . '=' .rawurlencode($v);
And then change the array2xml() function on line 492 so that $escape defaults to false:
function array2xml( $arr, $indent = '', $escape =false )
Also, I haven't seen this mentioned elsewhere, but if your server has PHP built with SOAP enabled, it's probably easier to just use the native SOAP support.
Hey Shane, are you using the latest code from GitHub?
If so, I believe the encoding problem you mentioned should not occur. I added the fixEncoding function to address this very issue.
Let me know if it's still an issue if you're using the latest code. Thanks.
Where in the code should I update the fixed utf-8 issue?
I am using the Campagin Monitor contact form 7 plugin
Got it, thanks
Just copied all the code from GitHub into the campaignmonitor.php file
the hebrew encoding now works!
From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that drive real business results.Get started for free