How to create a campaign using mailchimp v3.0

前端 未结 3 1899
旧时难觅i
旧时难觅i 2021-01-06 18:54

I am trying to create a new campaign using MailChimp API v3.0 but I do not see any method that allows me to make this in the resources of the API. Does anyone know how I ca

3条回答
  •  [愿得一人]
    2021-01-06 19:17

    PHP solution using POST request:

    //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 "
       ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
       $response = $err;
    }
    

提交回复
热议问题