// API to mailchimp ########################################################
$list_id = '7c5f7ad979';
$authToken = 'affe8d215db0b33e1fb22de12c565e17-us6';
// The data to send to the API
$postData = array(
"email_address" => $discountEmail,
"status" => "subscribed"
);
// Setup cURL
$ch = curl_init('https://us6.api.mailchimp.com/3.0/lists/'.$list_id.'/members/');
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Authorization: apikey '.$authToken,
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode($postData)
));
// Send the request
$response = curl_exec($ch);
Note: URL https://us6 depands on user location such as us12 etc