當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。