当前位置: 首页>>代码示例>>PHP>>正文


PHP MCAPI::listStaticSegmentMembersAdd方法代码示例

本文整理汇总了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();
 }
开发者ID:quadra-digital,项目名称:silverstripe-mailchimp-module,代码行数:54,代码来源:MyManyManyList.php


注:本文中的MCAPI::listStaticSegmentMembersAdd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。