I'm trying to make subscriberAddWithCustomFields works with the PHP Sample and I'm having problems for the last 5 hours with it, so it's time to ask for a little help
I have a list with two custom fields, one is Multi-Options (select many) (called 'opcoes'), and the other is a Multi-Options (select one)(called 'mes'), and I can't figure out how I need to code this to make it insert the two fields heres my code:
$api_key = 'APIKEY';
$list_id = 'LISTID';
$cm = new CampaignMonitor($api_key, null, null, $list_id,'soap');
$userEmail = "EMAIL";
$userName = "NAME";
$informations = array('opcoes' => 'Taco el Pancho', 'Todos'), array('mes' => 'mar')
$result0 = $cm->subscriberAddWithCustomFields($userEmail, $userName, $informations);
$result1 = $cm->subscribersGetActive();
print_r($result0); //Array ( [code] => 0 [Message] => Success )
print_r($result1); // It's empty ( how I can Successfully add, and the user don't show up it's weird to me, I've tried without the $informations bit and the result is the same )[/code]
Any Clue ??
And please CM, could you add some simple examples about using the API Samples ?
You need to use this following line:
$informations = array('opcoes' => array('Taco el Pancho', 'Todos'), 'mes' => 'mar');
This should work now.
The file Subscriber.AddWithCustomFields.php from http://www.campaignmonitor.com/api/kits/#php-sample does have an example of how to format the custom field array.
Feel free to get back to us if you have any other problems or questions.
Thanks for the response, After a couple of more try and error I came up with:
$informations = array("opcoes" =>array ( "taco el pancho","soviet"), "mes" =>array ("mar"));
which is the same thing, actually it was more of a lack of knowledge of php from my part than anything else.
I'm having similar problems getting this to work. I've tried the suggestions above but no joy :(
Script is as follows:
$api_key = 'my_api_key';
$client_id = null;
$campaign_id = null;
$list_id = 'my_list_id';
$cm = new CampaignMonitor( $api_key, $client_id, $campaign_id, $list_id, 'soap');
$result = $cm->subscriberAddWithCustomFields($Email, $Name, array('Title' => $Title));
if($result['Code'] == 0)
echo 'Error : ' . $result['Message'];
I have the permissions of both this and the CMBase.php set to 755.
The variables $Email, $Name, and $Title are passed from a form which uses a POST action pointing at this php script.
Can anyone tell me what I'm doing wrong?
I couldn't figure out what was wrong, but maybe:
array('Title' => $Title)
array('Title' => '$Title')