这是我的做法:
$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