本文整理汇总了PHP中MCAPI::listStaticSegmentMembersDel方法的典型用法代码示例。如果您正苦于以下问题:PHP MCAPI::listStaticSegmentMembersDel方法的具体用法?PHP MCAPI::listStaticSegmentMembersDel怎么用?PHP MCAPI::listStaticSegmentMembersDel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCAPI
的用法示例。
在下文中一共展示了MCAPI::listStaticSegmentMembersDel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onUnlink
public function onUnlink($item)
{
$apikey = SiteConfig::current_site_config()->getMCAPIKey();
$api = new MCAPI($apikey);
// Define Child/Parent Objects Being Related Based on ManyManyList's (the Parent Class) localKey/foreignKey Fields
$mid = $this->getField($this->getForeignKey());
$eid = $this->getField($this->getLocalKey());
$member = Member::get()->byID($mid);
$event = MCEvent::get()->byID($eid);
if (!is_object($event) || !$event->exists()) {
SS_Log::log('MyManyManyList::onUnlink - No valid event object found, ID: ' . $eid, SS_Log::ERR);
return;
} else {
if (!is_object($member) || !$member->exists()) {
SS_Log::log('MyManyManyList::onUnlink - No valid member object found, ID: ' . $mid, SS_Log::ERR);
return;
}
}
$segments = $event->getComponents("MCListSegments");
// Mailchimp Static Segment Removal Logic
if (!empty($segments)) {
foreach ($segments as $segment) {
$list = $segment->getComponent("MCList");
// Get All Subscription Records This Member Has For This List
// The Fact That This Could Include Subscriptions Which Arnt Actually In This Static Segment
// (i.e Unsubscribed Subs and/or Newly Added Subs Since SegmentMembersAdd() Was Run)
// Means We Are Liable To Get API Call Erros, They Should Not Do Any Harm Though
$subs = $member->getComponents("MCSubscriptions", "\"MCListID\" = '" . $list->ID . "'");
if ($subs->count() > 0) {
// An Array of E-mail Address or MailChimp Provided ID's For Identifying Records
$identifiers = array();
foreach ($subs as $sub) {
$identifiers[] = $sub->getMailChimpIdentifier();
SS_Log::log("MC Identifier: " . $sub->getMailChimpIdentifier(), SS_Log::NOTICE);
}
$api->listStaticSegmentMembersDel($list->ListID, $segment->MCListSegmentID, $identifiers);
if ($api->errorCode) {
SS_Log::log("API Call Failed: listStaticSegmentMembersDel(" . $list->ListID . ", " . $segment->MCListSegmentID . ", " . $identifiers . "); | Error Code = " . $api->errorCode . " | Error Message = " . $api->errorMessage, SS_Log::ERR);
} else {
SS_Log::log("API Call Success: listStaticSegmentMembersDel(" . $list->ListID . ", " . $segment->MCListSegmentID . ", " . $identifiers . ");", SS_Log::NOTICE);
}
}
}
}
}