本文整理汇总了PHP中MCAPI::listStaticSegmentAdd方法的典型用法代码示例。如果您正苦于以下问题:PHP MCAPI::listStaticSegmentAdd方法的具体用法?PHP MCAPI::listStaticSegmentAdd怎么用?PHP MCAPI::listStaticSegmentAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCAPI
的用法示例。
在下文中一共展示了MCAPI::listStaticSegmentAdd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
if ($this->isChanged("ID") && $this->getFirstWrite() && $this->getSyncMailChimp()) {
$apikey = SiteConfig::current_site_config()->getMCAPIKey();
$api = new MCAPI($apikey);
$list = $this->getComponent("MCList");
if (!empty($list)) {
// Limitited to 50 Bytes (Hopefully 50 Chars)
$SegmentTitle = substr($this->Title, 0, 45);
$api->listStaticSegmentAdd($list->ListID, $SegmentTitle);
if ($api->errorCode) {
SS_Log::log("API Call Failed: listStaticSegmentAdd(); | Error Code = " . $api->errorCode . " | Error Message = " . $api->errorMessage, SS_Log::ERR);
} else {
SS_Log::log("API Call Success: listStaticSegmentAdd();", SS_Log::NOTICE);
// Make Second Call To Return MailChimp Segment ID
$segments = $api->listStaticSegments($list->ListID);
foreach ($segments as $segment) {
// Make Sure We Capture the WHOLE Event ID!
$id_chars = strlen((string) $this->EventID);
$id = substr($segment['name'], 6, $id_chars);
if ($id == $this->EventID) {
SS_Log::log("This Event ID = " . $this->EventID . ", Static Segment Named " . $segment['name'] . " Relates to Event ID " . $id, SS_Log::NOTICE);
SS_Log::log("We Have a Match", SS_Log::NOTICE);
$this->setField("MCListSegmentID", $segment['id']);
$this->write();
break;
}
}
}
}
}
// END: if($this->isChanged("ID")) {
$this->setFirstWrite(false);
}