New to the Campaign Monitor API...
Trying to add users to a list from my own modx site. I've 2 custom fields, One a text field the other a multi select. Using the code below just adding one of the custom fields (from the text field) nothing happens, not errors. (it bombs out during $wrap->add and goes no further )
If i remove the custom field from the submission, and just send the name and email - it adds the person fine.
$wrap = new CS_REST_Subscribers($list_id, $api_key); $result = $wrap->add(array( 'EmailAddress' => $_POST ["email"], 'Name' => $name, 'CustomFields' => array( array( 'Key' => 'Organisation', 'Value' => $organisation ) ), 'Resubscribe' => true ));
got it working with v2 of the API...
Hi, I see your using PHP. Just a thought, if the code is working with v2 of the API, are you using the latest v3 PHP wrapper for the v3 API?
Sorry.. with v3 of the php wrapper (code above) i can't get it working. When i pass the custom fields data into $wrap->add() it dies. If i remove the custom fields and just submit the persons name and email it works.
I've gone back to using the old wrapper CMBase.php lib and $cm->subscriberAddWithCustomFields() works.
Hi there, when you say it bombs out or dies, is there a specific error your seeing?
So we can help you further, would you mind sending the following to email@example.com
* Account URL - such as company.createsend.com
* The client and list your using.
We'll be able to take a look and get back to you.
I'm outputting data to my console log before and after the $wrap->add call.
When the customfields are included, the second log isn't recorded. and nothing else happens. So it is stopping/ dying during the $wrap->add call.
I'm also having the same problem. I can add a new subscriber, but the custom field data is empty when I view the subscriber in Campaign Monitor. My code is:
$wrap = new CS_REST_Subscribers('$listid', '$apikey'); $result = $wrap->add(array( 'EmailAddress' => 'firstname.lastname@example.org', 'Name' => 'imagic API test', 'CustomFields' => array( array( 'Company' => 'imagic company test', 'Title' => 'imagic title test' ) ), 'Resubscribe' => true ));
Am I doing something wrong?
Nevermind.. I had the custom fields array wrong:)
Correctly should have been:
'CustomFields' => array( array( 'Key' => 'Company', 'Value' => 'imagic company test' ), array( 'Key' => 'Title', 'Value' => 'imagic titlef test' ), ),
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