Skip to content

Instantly share code, notes, and snippets.

@AshikNesin
Created October 24, 2016 06:40
Show Gist options
  • Save AshikNesin/96a406b684f6b7de653cee83680a51dd to your computer and use it in GitHub Desktop.
Save AshikNesin/96a406b684f6b7de653cee83680a51dd to your computer and use it in GitHub Desktop.
MailChimp Single Optin
<?php
// error_reporting(E_ALL);
// ini_set('display_errors', 1);
// switch ($_SERVER['HTTP_ORIGIN']) {
// case 'http://www.ios.buyselltickets.in': case 'http://ios.buyselltickets.in':
// header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
// header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
// header('Access-Control-Max-Age: 1000');
// header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
// break;
// }
include('./src/MailChimp.php');
use \DrewM\MailChimp\MailChimp;
$MailChimp = new MailChimp('API_KEY');
$list_id = 'LIST_ID';
$email_id = $_POST["EMAIL"];
$result = $MailChimp->post("lists/$list_id/members", [
'email_address' => $email_id,
'status' => 'subscribed',
]);
echo json_encode($result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment