function _unsubscribe($email) { $result = $this->cm->subscriberUnsubscribe($email); if ($result['Result']['Code'] == 0) { return true; } else { trigger_error('Campaign Monitor Error: ' . $result['Result']['Message']); } }
function __actionIndex() { $checked = @array_keys($_POST['items']); if (is_array($checked) && !empty($checked)) { //Get Campaign Monitor preferences $api_key = $this->_Parent->Configuration->get('api_key', 'campaign_monitor'); $list_id = $this->_Parent->Configuration->get('list_id', 'campaign_monitor'); //New Campaign Monitor instance $cm = new CampaignMonitor($api_key); switch ($_POST['with-selected']) { case 'unsubscribe': foreach ($checked as $subscriber) { $result = $cm->subscriberUnsubscribe($subscriber, $list_id, false); } redirect($this->_Parent->getCurrentPageURL()); break; } } }
/** * delete user from campaign monitor system * * Cmintegration::factory()->delete_user($email, $list_id); * * @param string $data * @return void * @author Dan Chadwick */ public function delete_user($email, $list_id = null) { $list_id = !empty($list_id) ? $list_id : $this->list_id; $cm = new CampaignMonitor($this->api_key, $this->client_id, $this->campaign_id, $list_id); if (is_array($email)) { foreach ($email as $e) { $result = $cm->subscriberUnsubscribe($e); } } else { // This is the actual call to the method, passing email address, name. $result = $cm->subscriberUnsubscribe($email); } if ($result['Result']['Code'] == 0) { return true; } else { Kohana::log('error', 'Campaign Monitor Error : ' . $result['Result']['Message']); return false; } }
<?php //Sample using the CMBase.php wrapper to call Subscriber.AddWithCustomFields from any version of PHP //Relative path to CMBase.php. This example assumes the file is in the same folder require_once 'CMBase.php'; //Your API Key. Go to http://www.campaignmonitor.com/api/required/ to see where to find this and other required keys $api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $client_id = null; $campaign_id = null; $list_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $cm = new CampaignMonitor($api_key, $client_id, $campaign_id, $list_id); //Optional statement to include debugging information in the result //$cm->debug_level = 1; //This is the actual call to the method, passing email address, name. $result = $cm->subscriberUnsubscribe('*****@*****.**'); if ($result['Result']['Code'] == 0) { echo 'Success'; } else { echo 'Error : ' . $result['Result']['Message']; } //Print out the debugging info //print_r($cm);