如何使用 mailchimp v3.0 创建活动

How to create a campaign using mailchimp v3.0

我正在尝试使用 MailChimp API v3.0 创建一个新的活动,但我没有在 API 的资源中看到任何允许我进行此活动的方法。 有谁知道我该怎么做?

我最初回答这个问题时这是不可能的,但 API 已更新为包括 campaign creation

向此地址发送 POST 请求

"https://us15.api.mailchimp.com/3.0/campaigns?apikey=****"

原始数据附件中包含以下内容。

{
    "type":"regular",
"list_id":"****",
"subject_line":"Your Purchase Receipt",
"reply_to":"Email@email.com",
"from_name":"Customer Service",
"settings":{"subject_line":"Your Purchase Receipt","reply_to":"Email@email.com","from_name":"Customer Service"}

}

有关更多信息,请参阅以下文档。 http://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/#create-post_campaigns

PHP 解决方案使用 POST 请求:

//Sample Data
$data = array("recipients" => array("list_id" => "205d96e6b4"), "type" => "regular", "settings" => array("subject_line" => "Subject", "title" => "Title", "reply_to" => "test@gmail.com", "from_name" => "Test", "folder_id" => "8888969b77"));
$data = json_encode($data);
$curl = curl_init();
curl_setopt_array($curl, array(    
   //Sample url
   CURLOPT_URL => "https://xxx.api.mailchimp.com/3.0/campaigns",
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_TIMEOUT => 30,
   CURLOPT_CUSTOMREQUEST => "POST",
   CURLOPT_POSTFIELDS => $data,
   CURLOPT_HTTPHEADER => array(
      "authorization: apikey <your_apikey>"
   ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
   $response = $err;
}