【发布时间】:2018-05-08 22:10:21
【问题描述】:
我想通过 MailChimp API 创建活动。我正在使用下面的代码。
$data = ["recipients" => ["list_id" => "a332819b0b"], "type" => "regular", "settings" => ["subject_line" => "Subject", "title" => "Title", "reply_to" => "test@gmail.com", "from_name" => "Test"]];
$data = json_encode($data);
$curl = curl_init();
curl_setopt_array($curl, [
//Sample url
CURLOPT_URL => "https://us17.api.mailchimp.com/3.0/campaigns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => ["apikey:MY_API_KEY"],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
$response = $err;
}
die($response);
我得到如下输出。
谁能帮我解决这个问题?谢谢。
【问题讨论】:
-
我建议更改您帐户的 API 密钥,因为它是私有的。您可以follow the steps here 禁用此问题中的密钥并生成一个新密钥,以便其他人无法访问您的帐户。