Skip to content

Instantly share code, notes, and snippets.

@DZuz14
Last active June 28, 2017 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DZuz14/380454b5ad2d862c521ab09289903842 to your computer and use it in GitHub Desktop.
Save DZuz14/380454b5ad2d862c521ab09289903842 to your computer and use it in GitHub Desktop.
Mailchimp API
<?php
$MailChimp = new MailChimp('insert api key here');
$list_id = 'gmj87s22'; // Mailchimp List Id
$email = $_POST['email'];
$first_name = $_POST['firstName'];
$last_name = $_POST['lastName'];
$result = $MailChimp->post("lists/$list_id/members", [
'email_address' => $email,
'merge_fields' => [
'FNAME' => $first_name,
'LNAME' => $last_name
],
'status' => 'subscribed'
]);
if ($MailChimp->success()) {
echo 'Thanks for signing up. Your submittal was successful.';
} else {
echo 'Something went wrong. You may already be subscribed.';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment