简体   繁体   English

MailChimp API更新列表详细信息

[英]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. 在我们网站的第1页,我们使用mailchimp API将用户电子邮件和其他一些细节插入到mailchimp列表中。

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. 在稍后的页面上,我们想要更新该人的mailchimp记录并包含一些其他信息。需要一些UPDATE API编码的帮助。

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方法。

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. 确保您将update_existing设置为TRUE。

It will update existing entry in subscribed list. 它将更新订阅列表中的现有条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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