通过API v3将Mailchimp广告系列发送到特定的电子邮件地址

时间:2019-06-17 23:50:43

标签: php mailchimp-api-v3.0

我有以下代码,但出现resource not found错误。 是否有人成功将MC广告系列发送给单个用户?

  $apiKey = 'APIKEYHERE';
  $campaignId = 'CAMPAIGNIDHERE';

  $memberId = md5(strtolower("test@example.com"));
  $dataCenter = 'us19';
  $url = 'https://'. $dataCenter . '.api.mailchimp.com/3.0/campaigns/' . $campaignId .'/actions/test';

  $jsonEmail = '{}';

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_USERPWD, 'apikey:'.$apiKey);
  curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonEmail);

  $result = curl_exec($ch);
  curl_close($ch);

  var_dump($result);

0 个答案:

没有答案