$email,
“fields” => array(
“first_name” => $first_name,
“last_name” => $last_name
),
“group_ids” => $groups
);
// Set URL
$url = “https://api.e2ma.net/”.$account_id.”/members/add”;
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_USERPWD, $public_api_key . “:” . $private_api_key);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($member_data));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($member_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-type: application/json’));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$head = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$result = json_decode($head, true);
//execute post
if($http_code > 200) {
$app_message = “Error sending subscription request. Please try again later.”;
// print_r($head);
} else {
// print_r($head);
if ($result[“added”] == “true”) {
$app_message = “
Thank you for subscribing to our newsletter. A confirmation email has been sent to your inbox. Please check and confirm your email address to receive health and wellness tips from Dr. King.
“;
} else { $app_message = “
Error sending subscription request. You are already subscribed!
“; }
}
//echo(“
code: ” .$http_code. “
“);
//echo(“
test: ” .$result[“added”]. “
“);
echo $app_message;
?>
