本文整理汇总了PHP中MCAPI::listUnsubscribe方法的典型用法代码示例。如果您正苦于以下问题:PHP MCAPI::listUnsubscribe方法的具体用法?PHP MCAPI::listUnsubscribe怎么用?PHP MCAPI::listUnsubscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCAPI
的用法示例。
在下文中一共展示了MCAPI::listUnsubscribe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unsubscribe
/**
* Unsubscribe an e-mail to a list.
*
* @param int $listId The id of the list to unsubscribe from
* @param string $email The email address to unsubscribe from.
* @return bool True if email was unsubscribed successfully.
*/
public function unsubscribe($listId, $email)
{
// Clear the cache for members in list
$cacheName = $this->__getCacheName('list_subscribed_members', array($listId));
$this->__clearMailchimpCache($cacheName);
return $this->__api->listUnsubscribe($listId, $email);
}
示例2: mc_remove_email
function mc_remove_email($email_address)
{
require_once DIR_WS_CLASSES . 'MCAPI.class.php';
$api = new MCAPI(MAILCHIMP_API);
$email = $newsletter['customers_email_address'];
$retval = $api->listUnsubscribe(MAILCHIMP_ID, $email, MAILCHIMP_DELETE, MAILCHIMP_SEND_GOODBYE, MAILCHIMP_SEND_NOTIFY);
}
示例3: moveSubscriber
public function moveSubscriber()
{
$api = new MCAPI($this->_apiKey);
$retval = $api->lists();
if ($api->errorCode) {
Mage::getSingleton('core/session')->addError($this->__('Error: %s', $api->errorMessage));
} else {
foreach ($retval['data'] as $val) {
if ($val['name'] === "Prospects") {
$prospectListId = $val['id'];
} elseif ($val['name'] === "Fashion Eyewear Customers") {
$customerListId = $val['id'];
}
}
if ($api->errorCode != '') {
// an error occurred while logging in
Mage::log('Error Code: ' . $api->errorCode);
Mage::log('Error Message: ' . $api->errorMessage);
die;
}
$retval = $api->listMembers($prospectListId, 'subscribed', null, 0, 10000);
//var_dump($retval);die;
if (!$retval) {
Mage::log('Error Code: ' . $api->errorCode);
Mage::log('Error Message: ' . $api->errorMessage);
} else {
foreach ($retval['data'] as $member) {
//echo $member['email']." - ".$member['timestamp']."<br />";
$customerModel = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('email', $member['email'])->setPage(1, 1);
$customers = $customerModel->getData();
$customerId = $customers[0]['entity_id'];
$orders = Mage::getResourceModel('sales/order_collection')->addFieldToSelect('*')->addFieldToFilter('customer_id', $customerId)->getData();
if (!empty($orders)) {
//if ($member['email'] === 'ruffian.ua@gmail.com') {
$memInfo = $api->listMemberInfo($prospectListId, array($member['email']));
$firstname = $memInfo['data'][0]['merges']['FNAME'];
if (empty($firstname)) {
$firstname = Mage::getModel('customer/customer')->load($customerId)->getFirstname();
}
$retuns = $api->listUnsubscribe($prospectListId, $member['email'], 1);
if (!$retuns) {
Mage::log('Unsubscribe Error Code: ' . $api->errorCode);
Mage::log('Unsubscribe Error Message: ' . $api->errorMessage);
}
$merge_vars = array('FNAME' => $firstname);
$retsub = $api->listSubscribe($customerListId, $member['email'], $merge_vars);
if (!$retsub) {
Mage::log('Subscribe Error Code: ' . $api->errorCode);
Mage::log('Subscribe Error Message: ' . $api->errorMessage);
}
//}
}
}
}
}
}
示例4: unSubscribe
function unSubscribe($userId = null, $listId = null, $email = null)
{
App::import('Vendor', 'MCAPI', array('file' => 'MCAPI.class.php'));
$MCapi = new MCAPI(MCLOGIN, MCPASSWORD);
$mcListId = $this->field('chimpid', array('id' => $listId));
if (!$mcListId) {
return false;
}
$this->MailinglistUser->deleteAll("mailinglist_id = {$listId} AND user_id = {$userId}");
/*Remove from the list*/
$result = $MCapi->listUnsubscribe($mcListId, $email, true, true, false);
//pr($MCapi->errorCode);
}
示例5: unsubscribe
function unsubscribe()
{
$api_key = $this->EE->TMPL->fetch_param('api_key');
$list_id = $this->EE->TMPL->fetch_param('list_id');
$email_address = $this->EE->TMPL->fetch_param('email_address');
if (!$api_key or !$list_id or !$email_address) {
return;
}
$api = new MCAPI($api_key);
$result = $api->listUnsubscribe($list_id, $email_address);
if ($api->errorCode) {
$this->EE->TMPL->log_item('Mailchimp EE: Unsubscribe failed, Mailchimp API complained - ' . $api->errorMessage . ' (' . $api->errorCode . ')');
}
}
示例6: mailChimpUnsubscribe
public function mailChimpUnsubscribe($data)
{
if (!$data['email']) {
return "No email address provided";
}
if (!preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\$/i", $data['email'])) {
return "Email address is invalid";
}
require_once '/var/www/system/library/MCAPI.class.php';
$api = new MCAPI('YOUR_API_KEY');
if ($api->listUnsubscribe("YOUR_LIST", $data['email'])) {
echo 'Success! Check your email to confirm sign up.';
return 'Success! Check your email to confirm sign up.';
} else {
echo 'Error: ' . $api->errorMessage;
return 'Error: ' . $api->errorMessage;
}
}
示例7: cancel
public static function cancel($params)
{
$result = array();
$result['success'] = true;
if(empty($params['allow_work']))
{
$result['success'] = false;
$result['title'] = 'Error';
$result['content'] = JText::_("Error");
return $result;
}
unset($params['allow_work']);
$db = oseDB::instance();
$msc_id =$params['msc_id'];
$member_id = $params['member_id'];
// get the list id of msc
$query = "SELECT * FROM `#__osemsc_ext` WHERE `id` = '{$msc_id}' AND `type` = 'mailchimp'";
$db->setQuery($query);
$data = $db->loadObject();
$data = oseJson::decode($data->params);
if(empty($data->list_id) || empty($data->enable) || empty($data->unsubscribe_enable))
{
$result['success'] = true;
$result['title'] = JText::_('Done');
$result['content'] = JText::_("Done");
return $result;
}
require_once(OSEMSC_B_LIB.DS.'MCAPI.class.php');
$oseMscConfig= oseRegistry :: call('msc')->getConfig(null, 'obj');
$APIKey = $oseMscConfig->mailchimp_api_key;
$api = new MCAPI($APIKey);
$query = "SELECT email FROM `#__users` WHERE `id` = ".(int) $member_id;
$db->setQuery($query);
$email = $db->loadResult();
$MC_MemInfo = $api->listMemberInfo($data->list_id,$email);
if($MC_MemInfo['success'])
{
$api->listUnsubscribe($data->list_id,$email,$data->delete,$data->sendGoodbye,$data->sendNotify);
}
return $result;
}
示例8: onAfterDelete
public function onAfterDelete()
{
// If Deletion Is Triggered By A Sync Where The Record Has Already Been Deleted In MC The Sync Flag Will Be False
if ($this->getSyncMailChimp()) {
$apikey = SiteConfig::current_site_config()->getMCAPIKey();
$api = new MCAPI($apikey);
// Define Related MCList Object
$list = $this->getComponent("MCList");
// Execute the Unsubscribe Call
$result = $api->listUnsubscribe($list->ListID, $this->getMailChimpIdentifier(), true);
if ($result) {
SS_Log::log("API Call Success: listUnsubscribe(" . $list->ListID . ", " . $this->getMailChimpIdentifier() . ", \$delete_member = true); for Subscription ID " . $this->ID, SS_Log::NOTICE);
} else {
SS_Log::log("API Call Failed: listUnsubscribe(" . $list->ListID . ", " . $this->getMailChimpIdentifier() . ", \$delete_member = true); for Subscription ID " . $this->ID . " | Error Code = " . $api->errorCode . " | Error Message = " . $api->errorMessage, SS_Log::ERR);
}
}
}
示例9: sendMailChimpNotification
function sendMailChimpNotification()
{
$mainframe = JFactory::getApplication();
// listSubscribe(string apikey, string id, string email_address, array merge_vars, string email_type, boolean double_optin, boolean update_existing, boolean replace_interests, boolean send_welcome)
if (!class_exists('MCAPI')) {
require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/mailchimp/MCAPI.class.php';
}
if (trim($this->formrow->mailchimp_email_field) != '' && trim($this->formrow->mailchimp_api_key) != '' && trim($this->formrow->mailchimp_list_id) != '' && count($this->maildata)) {
$email = '';
$htmlTextMobile = 'text';
$checked = true;
$unsubsribe = false;
$mergeVars = array();
$htmlTextMobileField = trim($this->formrow->mailchimp_text_html_mobile_field);
$checkboxField = trim($this->formrow->mailchimp_checkbox_field);
$unsubscribeField = trim($this->formrow->mailchimp_unsubscribe_field);
$emailField = trim($this->formrow->mailchimp_email_field);
$mergeVarFields = explode(',', str_replace(' ', '', $this->formrow->mailchimp_mergevars));
$api = new MCAPI(trim($this->formrow->mailchimp_api_key));
$list_id = trim($this->formrow->mailchimp_list_id);
if ($checkboxField != '') {
$box = JRequest::getVar('ff_nm_' . $checkboxField, array(''));
if (isset($box[0]) && $box[0] != '') {
$checked = true;
} else {
$checked = false;
}
}
if ($unsubscribeField != '') {
$box = JRequest::getVar('ff_nm_' . $unsubscribeField, array(''));
if (isset($box[0]) && $box[0] != '') {
$unsubsribe = true;
}
}
if ($htmlTextMobileField != '') {
$selection = JRequest::getVar('ff_nm_' . $htmlTextMobileField, array(''));
if (isset($selection[0]) && $selection[0] != '') {
$htmlTextMobile = $selection[0];
}
} else {
$htmlTextMobile = $this->formrow->mailchimp_default_type;
}
foreach ($this->maildata as $data) {
switch ($data[_FF_DATA_NAME]) {
case $emailField:
$email = bf_is_email(trim($data[_FF_DATA_VALUE])) ? trim($data[_FF_DATA_VALUE]) : '';
break;
default:
if (in_array($data[_FF_DATA_NAME], $mergeVarFields)) {
$mergeVars[$data[_FF_DATA_NAME]] = $data[_FF_DATA_VALUE];
}
}
}
if ($email != '' && $checked) {
if ($api->listSubscribe($list_id, $email, count($mergeVars) == 0 ? '' : $mergeVars, $htmlTextMobile, $this->formrow->mailchimp_double_optin, $this->formrow->mailchimp_update_existing, $this->formrow->mailchimp_replace_interests, $this->formrow->mailchimp_send_welcome) !== true) {
if ($this->formrow->mailchimp_send_errors) {
$from = $this->formrow->alt_mailfrom != '' ? $this->formrow->alt_mailfrom : $mainframe->getCfg('mailfrom');
$fromname = $this->formrow->alt_fromname != '' ? $this->formrow->alt_fromname : $mainframe->getCfg('fromname');
$this->sendMail($from, $fromname, $from, 'MailChimp API Error', 'Could not send data to MailChimp for email: ' . $email . "\n\nReason (code " . $api->errorCode . "): " . $api->errorMessage);
}
}
}
if ($email != '' && $unsubsribe) {
if ($api->listUnsubscribe($list_id, $email, $this->formrow->mailchimp_delete_member, $this->formrow->mailchimp_send_goodbye, $this->formrow->mailchimp_send_notify) !== true) {
if ($this->formrow->mailchimp_send_errors) {
$from = $this->formrow->alt_mailfrom != '' ? $this->formrow->alt_mailfrom : $mainframe->getCfg('mailfrom');
$fromname = $this->formrow->alt_fromname != '' ? $this->formrow->alt_fromname : $mainframe->getCfg('fromname');
$this->sendMail($from, $fromname, $from, 'MailChimp API Error', 'Could not send unsubscribe data to MailChimp for email: ' . $email . "\n\nReason (code " . $api->errorCode . "): " . $api->errorMessage);
}
}
}
}
}
示例10: setMemberSubscription
public function setMemberSubscription($subscribe = true, $groups = array(), $send_confirmation = false)
{
/*
* Subscribe or Unsubscribe member to MailChimp list, setting Interest Group preferences
*/
require_once 'mailchimp-api/MCAPI.class.php';
require_once 'mailchimp-api/config.inc.php';
$mc_api = new MCAPI($mailchimp_api_key);
if ($subscribe) {
$merge_vars = array('');
// '' necessary
if (isset($this->nameFirst)) {
$merge_vars['FNAME'] = $this->nameFirst;
}
if (isset($this->nameLast)) {
$merge_vars['LNAME'] = $this->nameLast;
}
$groups_str = implode(', ', $groups);
$merge_vars['INTERESTS'] = $groups_str;
$retval = array();
// Subscribe
// By default this sends a confirmation email ($double_optin=true);
// you will not see new members until the link contained in it is clicked!
$retval['success'] = $mc_api->listSubscribe($mailchimp_list_id, $this->emailAddress, $merge_vars, 'html', $send_confirmation, true, true, false);
// listSubscribe($id, $email_address, $merge_vars, $email_type='html', $double_optin=true, $update_existing=false, $replace_interests=true, $send_welcome=false)
$retval['msg'] = "Subscription for {$this->emailAddress} successfully applied. Groups: { {$groups_str} }.";
} else {
$retval['success'] = $mc_api->listUnsubscribe($mailchimp_list_id, $this->emailAddress, true);
// listUnsubscribe($id, $email_address, $delete_member=false, $send_goodbye=true, $send_notify=true)
$retval['msg'] = "{$this->emailAddress} successfuly unsubscribed (fully).";
}
if (!$retval['success']) {
if ($mc_api->errorCode) {
$retval['msg'] = "MailChimp Error (subscribing): " . $mc_api->errorMessage . " (Code: " . $mc_api->errorCode . ")";
} else {
$retval['msg'] = "Unknown MailChimp Error (subscribing).";
}
}
return $retval;
}
示例11: unSubscribeLender
function unSubscribeLender($email)
{
require_once 'mail_chimp/MCAPI.class.php';
require_once 'mail_chimp/config.inc.php';
//contains apikey
$api = new MCAPI($apikey);
$retval = $api->listUnsubscribe($listId, $email);
if ($api->errorCode) {
Logger_Array("Unable to load listSubscribe", 'Error Code, Error Message', $api->errorCode, $api->errorMessage);
} else {
Logger_Array("Unsubscribed", 'retval', $retval);
}
}
示例12: MCAPI
<?php
/**
This Example shows how to pull the Info for a Member of a List using the MCAPI.php
class and do some basic error checking.
**/
require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php';
//contains apikey
$api = new MCAPI($apikey);
$retval = $api->listUnsubscribe($listId, $my_email);
if ($api->errorCode) {
echo "Unable to load listUnsubscribe()!\n";
echo "\tCode=" . $api->errorCode . "\n";
echo "\tMsg=" . $api->errorMessage . "\n";
} else {
echo "Returned: " . $retval . "\n";
}
示例13: MCAPI
$newsletter_general = '0';
}
if ($newsletter_general != $newsletter['customers_newsletter']) {
$newsletter_general = $newsletter['customers_newsletter'] == '1' ? '0' : '1';
tep_db_query("update " . TABLE_CUSTOMERS . " set customers_newsletter = '" . (int) $newsletter_general . "' where customers_id = '" . (int) $customer_id . "'");
//Mail Chimp
if (MAILCHIMP_ENABLE == true) {
require_once DIR_WS_CLASSES . 'MCAPI.class.php';
require DIR_WS_FUNCTIONS . 'mailchimp_functions.php';
$api = new MCAPI(MAILCHIMP_API);
$list_id = MAILCHIMP_ID;
$email_address = $newsletter['customers_email_address'];
$email_format = $newsletter['customers_newsletter_type'];
if ($newsletter['customers_newsletter'] == '1') {
//unsubscribe
$retval = $api->listUnsubscribe($list_id, $email_address, MAILCHIMP_DELETE, MAILCHIMP_SEND_GOODBYE, MAILCHIMP_SEND_NOTIFY);
} else {
//subscribe
$merge_vars = array('');
if ($email_format == 'TEXT') {
$format = 'text';
} else {
$format = 'html';
}
$retval = $api->listSubscribe($list_id, $email_address, $merge_vars, $format, MAILCHIMP_OPT_IN, true);
}
// end if
}
// end if MAILCHIMP_ENABLE
}
// end if
示例14: MCAPI
function unsubscribe_mailchimp_user($email_address, $list)
{
global $premise_base;
require_once PREMISE_LIB_DIR . 'mailchimp_api/MCAPI.class.php';
$settings = $premise_base->get_settings();
$mailchimp = new MCAPI($settings['optin']['mailchimp-api']);
$mailchimp->listUnsubscribe($list, $email_address, false, false, empty($settings['optin']['mailchimp-single-optin']));
}
示例15: mailchimp_hook_check
function mailchimp_hook_check($vars)
{
// Load config
$data = select_query("tblmailchimpconf", "name, value", array());
while ($r = mysql_fetch_array($data)) {
switch ($r['name']) {
case "apikey":
$apikey = $r['value'];
break;
case "clientfield":
$clientfield = $r['value'];
break;
}
}
if ($apikey && $clientfield) {
$d = select_query("tblcustomfieldsvalues", "value", array("fieldid" => $clientfield, "relid" => $vars['userid']));
if (mysql_num_rows($d)) {
$r = mysql_fetch_array($d);
$res = explode("|", $r[0]);
$listid = $res[0];
$listname = $res[1];
}
$api = new MCAPI($apikey);
$lst = $api->lists();
$lists = $lst['data'];
if (isset($vars['olddata'])) {
$cfarr = array($vars['olddata']['customfields1'], $vars['olddata']['customfields2'], $vars['olddata']['customfields3'], $vars['olddata']['customfields4'], $vars['olddata']['customfields5'], $vars['olddata']['customfields6'], $vars['olddata']['customfields7'], $vars['olddata']['customfields8'], $vars['olddata']['customfields9'], $vars['olddata']['customfields10']);
$firstname = $vars['olddata']['firstname'];
$lastname = $vars['olddata']['lastname'];
foreach ($lists as $k => $v) {
if (in_array($v['name'], $cfarr)) {
$oldlist = array('name' => $v['name'], 'id' => $v['id']);
break;
}
}
} else {
$firstname = $vars['firstname'];
$lastname = $vars['lastname'];
}
$email = $vars['email'];
if ($listid != 'none' && $listid != '') {
$merge_vars = array('FNAME' => $firstname, 'LNAME' => $lastname);
$retval = $api->listSubscribe($listid, $email, $merge_vars, null, False);
if ($api->errorCode) {
$desc = $api->errorMessage;
$userid = $vars['userid'];
$query = "INSERT INTO tblactivitylog (date, description, user, userid) VALUES(now(), '{$desc}', 'System', '{$userid}')";
full_query($query);
}
} else {
$retval = $api->listUnsubscribe($listid, $email, False, False);
if ($api->errorCode) {
$desc = $api->errorMessage;
$userid = $vars['userid'];
$query = "INSERT INTO tblactivitylog (date, description, user, userid) VALUES(now(), '{$desc}', 'System', '{$userid}')";
full_query($query);
}
}
if (isset($oldlist) && $oldlist['id'] != $listid) {
$retval = $api->listUnsubscribe($oldlist['id'], $email, False, False);
if ($api->errorCode) {
$desc = $api->errorMessage;
$userid = $vars['userid'];
$query = "INSERT INTO tblactivitylog (date, description, user, userid) VALUES(now(), '{$desc}', 'System', '{$userid}')";
full_query($query);
}
}
}
}