以下是我的表现方式:
$debug = true;
$auth = base64_encode( 'user:'. APIKEY );
$data = array(
'schedule_time' => date('Y-m-d H:i:s',strtotime("+1 hour")),
'timewarp' => false
);
$json_data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://'.SERVER.'.api.mailchimp.com/3.0/campaigns/'.$campaign_id.'/actions/schedule');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Authorization: Basic '. $auth));
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
$result = curl_exec($ch);
if ($debug) {
var_dump($result);
}
这会出错:
schedule_time可能只有15分钟的时间间隔,例如13:15而不是13:10
答案 0 :(得分:0)
这是旧的,但也可以回答偶然发现的其他人:
因此,正如错误消息所示,您只能将广告系列安排在15分钟的时间内,例如X:00,X:15,X:30和X:45。因此你使用
日期(' Y-m-d H:我:s',strtotime(" + 1小时"))
意味着除非你得到一些非常好的时机,否则你的日程安排总会失败。
我发现有用的是为用户提供一个步长为15的Timepicker下拉列表:
$('.timepicker').timepicker({ 'scrollDefault': 'now', 'step': 15, 'timeFormat': 'H:i' });
除了典型的日期选择器,当触发调度时,我将两者合并为Mailchimp想要的ATOM格式:
var date = $("#schedule_date").val(); //Date from the Datepicker
var time = $("#schedule_time").val(); //Time from the 15min step Timepicker
var offset = new Date().getTimezoneOffset()/60; // I believe Mailchimp likes to have it in UTC
var datetime=new Date(date+'T'+time+':00'+((offset<0)?"+":"-")+((offset>-10 && offset<10)?"0":"")+offset+':00'); // Constructing ATOM time (example: 2005-08-15T15:52:01+00:00)
var datestring = datetime.toISOString();
datestring = datestring.substring(0, datestring.length - 5)+'+00:00';