本文整理汇总了PHP中MCAPI::listStaticSegmentMembersAdd方法的典型用法代码示例。如果您正苦于以下问题:PHP MCAPI::listStaticSegmentMembersAdd方法的具体用法?PHP MCAPI::listStaticSegmentMembersAdd怎么用?PHP MCAPI::listStaticSegmentMembersAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCAPI
的用法示例。
在下文中一共展示了MCAPI::listStaticSegmentMembersAdd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onLink
public function onLink($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::onLink - No valid event object found, ID: ' . $eid, SS_Log::ERR);
return;
} else {
if (!is_object($member) || !$member->exists()) {
SS_Log::log('MyManyManyList::onLink - No valid member object found, ID: ' . $mid, SS_Log::ERR);
return;
}
}
$segments = $event->getComponents("MCListSegments");
// Mailchimp Static Segment Addition Logic
if (!empty($segments)) {
foreach ($segments as $segment) {
$list = $segment->getComponent("MCList");
// Get All Subscription Records This Member Has For This List (Which Arnt Unsubscribed)
$subs = $member->getComponents("MCSubscriptions", "\"MCListID\" = '" . $list->ID . "' AND \"Subscribed\" = '1'");
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->listStaticSegmentMembersAdd($list->ListID, $segment->MCListSegmentID, $identifiers);
if ($api->errorCode) {
SS_Log::log("API Call Failed: listStaticSegmentMembersAdd(" . $list->ListID . ", " . $segment->MCListSegmentID . ", " . json_encode($identifiers) . "); | Error Code = " . $api->errorCode . " | Error Message = " . $api->errorMessage, SS_Log::ERR);
} else {
SS_Log::log("API Call Success: listStaticSegmentMembersAdd(" . $list->ListID . ", " . $segment->MCListSegmentID . ", " . json_encode($identifiers) . ");", SS_Log::NOTICE);
}
}
}
}
// // Send E-mail Confirmation of Event Attendance Update
// $email = new Email();
// $email->setFrom('noreply@example.com');
// $email->setBcc('admin@example.com');
// $email->setTo($member->Email);
// $email->setSubject('Event Attendance Updated');
// $email->setTemplate("EventAttendanceUpdated");
// $email->populateTemplate(array(
// 'Event' => $event,
// 'Member' => $member
// ));
// $email->send();
}