Skip to content

Instantly share code, notes, and snippets.

@sabaraouf
Last active January 17, 2016 01:29
Show Gist options
  • Save sabaraouf/8827680 to your computer and use it in GitHub Desktop.
Save sabaraouf/8827680 to your computer and use it in GitHub Desktop.
MailChimp API - Subscribe User
<?php
$api_key = "YOUR_API_KEY";
$list_id = "YOUR_LIST_ID";
require('Mailchimp.php');
$Mailchimp = new Mailchimp( $api_key );
$Mailchimp_Lists = new Mailchimp_Lists( $Mailchimp );
$subscriber = $Mailchimp_Lists->subscribe( $list_id, array( 'email' => htmlentities($_POST['email']) ) );
if ( ! empty( $subscriber['leid'] ) ) {
echo "success";
}
else
{
echo "fail";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment