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


PHP MCAPI::listStaticSegmentMembersDel方法代码示例

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


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