【发布时间】:2017-11-13 06:06:43
【问题描述】:
使用 MailChimp API 3。我正在尝试创建一个查询来获取当月发送的电子邮件数量。有谁知道这是一个可能的请求?
如果是这样,有人知道要进行正确的查询吗?
【问题讨论】:
使用 MailChimp API 3。我正在尝试创建一个查询来获取当月发送的电子邮件数量。有谁知道这是一个可能的请求?
如果是这样,有人知道要进行正确的查询吗?
【问题讨论】:
我已经解决了我的问题。如果它对其他人有帮助,我为达到所需结果所做的工作如下。
$firstofmonth = date("Y-m-01"); // Date from when you want the count to begin
$arr = array();
$ch = curl_init();
$url = "https://" . $server . "api.mailchimp.com/3.0/reports?since_send_time=" . $firstofmonth;
curl_setopt($ch, CURLOPT_USERPWD, 'apikey:' . $api_key);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Basic ' . $auth
));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
curl_close($ch);
$results = json_decode($result, true);
$reports = $results['reports'];
$emails_sent = 0;
foreach ($reports as $row){
$emails_sent += $row['emails_sent'];
}
$arr[] = array
(
"emailssent" => $emails_sent
);
echo json_encode($arr);
【讨论】: