Campaignmonitor: How do I update a multi-options (select many) field using PHP wrapper
This question refers to CampaignMonitor API PHP wrapper, function subscriberAddWithCustomFields().
In the CampaignMonitor back-end I created a custom multi-option (select many) field called 'Subscribedto' where the user can select (checkbox) which newsletter he likes to receive: 'News & Updates' and/or开发者_JS百科 'News from Partners'. Now I would like to update this field using the PHP API wrapper but can't figure out how to do this.
From my database:
'News & Updates' can be either 0 or 1 'News from Partners' can be either 0 or 1The following does not work:
$extras = array('Subscribedto'=>array("News & Updates"=>0,"News from Partners"=>1));
$cm_res = $cm->subscriberAddWithCustomFields($email,$name, $extras);
Their new v3 API makes this a lot easier. See http://www.campaignmonitor.com/forums/viewtopic.php?id=5166 in their forums for an answer.
Here's some sample code from one of my forms:
$wrap = new CS_REST_Subscribers($list_id, $api_key);
$result = $wrap->add(array(
'EmailAddress' => $email,
'Name' => '',
'CustomFields' => array(
array(
'Key' => 'Events',
'Value' => 'Event 1'
)
),
'Resubscribe' => true
));
//echo "Result of POST /api/v3/subscribers/{list id}.{format}\n<br />";
if($result->was_successful()) {
$success = true;
$message = 'Cool! We\'ll be in touch soon.';
} else {
$message = $result->response;
}
精彩评论