$email, 'status' => 'subscribed' ); if( !empty( $merge_vars ) ) { $data['merge_fields'] = $merge_vars; } $payload = json_encode($data); $auth = base64_encode( 'user:' . $apiKey ); $header = array(); $header[] = 'Content-type: application/json; charset=utf-8'; $header[] = 'Authorization: Basic ' . $auth; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $submit_url); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); $result = curl_exec($ch); curl_close($ch); $data = json_decode($result); if ( isset( $data->status ) AND $data->status == 'subscribed' ){ echo '{ "alert": "success", "message": "You have been successfully subscribed to our Email List." }'; } else { echo '{ "alert": "error", "message": "' . $data->title . '" }'; } } ?>