2017-06-11 7 views
-3

MailChimp APIを使用しています。3.今月に送信されたメールの量を取得するためのクエリを作成しようとしています。誰でもそれを知ることができますか?MailChimp API 3.0 - メール数

正しい質問があれば誰でも知ることができますか?

答えて

0

私は私の問題を解決しました。必要な結果を得るために私がやったことは、他の誰かを助けるならば、以下の通りです。

$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); 
関連する問題