Created
June 11, 2015 14:46
-
-
Save nczz/14b3161096c47a2c71b2 to your computer and use it in GitHub Desktop.
MailChimp PHP Curl Add member to list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$URL='http://us11.api.mailchimp.com/3.0/lists/LISTID/members'; | |
$data = array("email_address"=>"[email protected]","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