本文整理汇总了PHP中MCAPI::campaignSchedule方法的典型用法代码示例。如果您正苦于以下问题:PHP MCAPI::campaignSchedule方法的具体用法?PHP MCAPI::campaignSchedule怎么用?PHP MCAPI::campaignSchedule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCAPI
的用法示例。
在下文中一共展示了MCAPI::campaignSchedule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MCAPI
<?php
/**
This Example shows how to schedule a campaign for future delivery
via the MCAPI class.
**/
require_once '../mcapi.php';
require_once 'config/config.inc.php';
//contains apikey
$api = new MCAPI($apikey);
$schedule_for = '2018-04-01 09:05:21';
$retval = $api->campaignSchedule($campaignId, $schedule_for);
if ($api->errorCode) {
echo "Unable to Schedule Campaign!";
echo "\n\tCode=" . $api->errorCode;
echo "\n\tMsg=" . $api->errorMessage . "\n";
} else {
echo "Campaign Scheduled to be delivered {$schedule_for}!\n";
}
示例2: send_campaign
public function send_campaign()
{
$expected = array('db', 'lang', 'send_time', 'num_subscribers', 'action');
if (!$_POST) {
exit;
}
$this->campaign = array();
foreach ($_POST as $post => $value) {
if (in_array($post, $expected)) {
$this->campaign[$post] = $value;
}
}
$host = $this->host;
$lang = $this->campaign['lang'];
$db = $this->campaign['db'];
$action = $this->campaign['action'];
$send_time = $this->campaign['send_time'];
$api_key = $this->get_setting('api_key');
$html = $this->get_file("{$host}?lang={$lang}&production");
$html = $this->filter_html_campaign_code($html);
$campaign_type = $this->get_setting('type');
$formatted_db_name = str_replace('_', ' ', strtoupper($db));
//add into the $opts this EDMs specifics:
$opts = $this->get_setting('options');
$opts['list_id'] = $this->get_setting('prod_list');
$opts['title'] .= ' ' . $formatted_db_name;
$opts['subject'] = $this->extract_html_subject($html);
//add tracking code
$year = date('Y');
$db_key = strtoupper($db);
$opts['analytics'] = array('google' => $this->get_setting('campaign_name') . '_' . $year . '_' . $db_key);
$opts['authenticate'] = true;
$segment_opts = array('match' => 'all', 'conditions' => $this->get_mailchimp_sending_criteria($db));
$api = new MCAPI($api_key);
$campaign_id = $api->campaignCreate($campaign_type, $opts, array('html' => $html), $segment_opts);
if ($action === 'schedule') {
$local = $this->get_send_time_and_offset(false, false, $send_time);
$tmp = strtotime($send_time) - $local['total_offset'];
$send_time = date('Y-m-d H:i:s', $tmp);
$campaign_id = $api->campaignSchedule($campaign_id, $send_time);
}
if ($api->errorCode) {
$this->send_json(array('fail' => $api->errorMessage));
} else {
$this->set_cache($campaign_id);
$this->send_json(array('success' => $campaign_id));
}
exit;
}