Skip to content

Instantly share code, notes, and snippets.

@nczz
Created June 11, 2015 14:46
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 nczz/14b3161096c47a2c71b2 to your computer and use it in GitHub Desktop.
Save nczz/14b3161096c47a2c71b2 to your computer and use it in GitHub Desktop.
MailChimp PHP Curl Add member to list
<?php
$URL='http://us11.api.mailchimp.com/3.0/lists/LISTID/members';
$data = array("email_address"=>"xxX@sample.com","status"=>"subscribed","merge_fields"=>array("FNAME"=>"江","LNAME"=>"小屁","MMERGE3"=>"江小屁"));
$data_string = json_encode($data);
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
'Authorization: apikey ad607dexxxxxxxxxxcc6f91b7xxxxxx6-us11')
);
//$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code
$result=curl_exec($ch);
curl_close($ch);
echo $result;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment