UTF chars passing via *.php?email=ëäöü

I am trying to pass some UTF-8 data over simple Subscriber.AddWithCustomFields.php?email=ëäöü string, and it does not work. It is not adding a new subscriber. Everything works fine with ISO Latin 1 encoding.

header set to :
<?php header ('Content-type: text/html; charset=utf-8');

and addstring looks:
$result = $cm->subscriberAddWithCustomFields($id, $name, array('First Name' => $firstname, 'Last Name' => $lastname, 'Salutation' => $salutation));

Any clues? Thank you in advance!

tobyb tobyb, 8 years ago

Hi Andy,

Sorry about the delay, we've spent a while trying to work out why this wasn't working.

It looks like the API wrapper wasn't encoding UTF-8 data properly, we've just updated the code and released a new download which should fix this problem.

Let us know if you have any other issues.

andywhite, 8 years ago

Greetings, Toby

I've downloaded and updated CMBase.php.

I am trying to pass simple "üöäÄÖÜ" string, it still does not work — it updates the field with "üöäÄÖÃ" (UTF-8 in Safari) value.

Previously it was not adding/updating subscriber data at all.

andywhite, 8 years ago

bump!

still same problem :-(

andywhite, 8 years ago

bump! it does not work, any news on it?

jamesd jamesd, 8 years ago

Hi Andy,

Sorry this has been left so long without a response.

I've just written the following code (using the latest version of the PHP wrapper 1.4.2 from http://code.google.com/p/campaignmonitor-php/) to verify that the API works when I pass in the data you specified:

[code]ini_set ('display_errors', 1);
error_reporting (E_ALL);
require_once('CMBase.php');
$apikey = 'xxxxxxxxxxxxxxxxxxxxx';
$client_id = 'xxxxxxxxxxxxxxxxxxxxx';
$list_id = 'xxxxxxxxxxxxxxxxxxxxx';
$cm = new CampaignMonitor($apikey, $client_id, null, null, 'get');
$sub_add_result = $cm->subscriberAddWithCustomFields(
    'example@example.com',
     'üöäÄÖÜ',
    array(),
    $list_id,
    true);
print_r($sub_add_result);[/code]
This results in the subscriber being correctly added, including the correct assignment of the string "üöäÄÖÜ" as the subscriber's name, and the following response:

[code]Array
(
    [code] => 0
    [Message] => Success
)[/code]
The difference between the code above and what you're trying to achieve is that you're passing in data from the GET/POST variables.

So the problem as I see it is not with the handling of the data by the PHP API wrapper, but the format of the data being passed in from the GET/POST variables. Could you verify that the code above works for you if you enter the values manually as I have done?

marcalj, 7 years ago
jamesd :

So the problem as I see it is not with the handling of the data by the PHP API wrapper, but the format of the data being passed in from the GET/POST variables. Could you verify that the code above works for you if you enter the values manually as I have done?

I have problems with v1.4.3 PHP wrapper. Using API with manual values and POST (utf-8) values doesn't work.

"ñö

marcalj, 7 years ago

Hi... for some strange reason, PHP treats string as ISO8859-1... but all content and declaration is in UTF-8...

So, the solution is use "utf8_decode($name);".

See you!

200,000 companies around the world can't be wrong.

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
1-888-533-8098