1

I have got the following code but I'm getting a resource not found error. Has anyone successfully sent an MC campaign to a single user?

  $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);
PavKR
  • 1,591
  • 2
  • 11
  • 26

0 Answers0