【问题标题】:MailChimp API 3.0 - email countMailChimp API 3.0 - 电子邮件计数
【发布时间】:2017-11-13 06:06:43
【问题描述】:

使用 MailChimp API 3。我正在尝试创建一个查询来获取当月发送的电子邮件数量。有谁知道这是一个可能的请求?

如果是这样,有人知道要进行正确的查询吗?

【问题讨论】:

    标签: mailchimp-api-v3.0


    【解决方案1】:

    我已经解决了我的问题。如果它对其他人有帮助,我为达到所需结果所做的工作如下。

    $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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-21
      • 2016-05-25
      • 2012-08-13
      • 2011-05-07
      • 2018-07-13
      • 2016-06-21
      • 2016-08-03
      • 2012-11-15
      相关资源
      最近更新 更多