简体   繁体   中英

MailChimp API to Update List Details

On page 1 on our website we use the mailchimp API to insert the users email and some other details into a mailchimp list.

Now the issue. On a later page we want to update the mailchimp records for that person and include some other information.Need some help with the UPDATE API coding.

Thanks for your help.

Cheers

This is our insert coding:

 ** Store email to MailChimp database - start **/
   require_once('MCAPI.class.php');
   // grab an API Key from http://admin.mailchimp.com/account/api/
   $api = new MCAPI('XXXXXXXXXXXXXXXXXXXXXX');

   // grab your List's Unique Id by going to http://admin.mailchimp.com/lists/
   // Click the "settings" link for the list - the Unique Id is at the bottom of that page. 
   $list_id = "XXXXXXXXXXXXXXXXXXXXXX";

   $merge_vars = array('NAME'=> GetSQLValueString($_POST['name']), 'START'=>               GetSQLValueString($_POST['start']), 'SITE'=> GetSQLValueString($_POST['site']));

   if($api->listSubscribe($list_id, GetSQLValueString($_POST['email_address']), $merge_vars, 'html', FALSE) === true) {
     // It worked!
   }else{
     // An error ocurred, return error message - Don't uncomment this one
     //echo "Unable to load listSubscribe()!\n";
    //echo "\tCode=".$api->errorCode."\n";
    //echo "\tMsg=".$api->errorMessage."\n";
    //exit();
   }
   /** Store email to MailChimp database - end **/

You can use listSubscribe method for the same.

listSubscribe(string apikey, string id, string email_address, 
              array merge_vars, string email_type, bool double_optin, 
              bool update_existing, bool replace_interests, bool send_welcome)

Make Sure you set update_existing to TRUE.

It will update existing entry in subscribed list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM