Mailchimp API Gem - 保存其他合并字段

时间:2018-05-31 01:35:46

标签: ruby-on-rails mailchimp-api-v3.0

我正在使用MailChimp Gem将成员添加到我的MailChimp列表中。该成员正在添加正确的订阅状态,但我传递的是名字,姓氏,一些推荐代码和兴趣。但这些都没有得到妥善安排。这是我的代码。

mailchimp1.lists.subscribe("xxxxxxxxx", 
     { email => "srividhya@xxxxxx.com",
       status => "subscribed",
       merge_fields =>  (MMERGE1 = "srividhya", MMERGE2 = "prakash", MMERGE3 = "srip1" ),
       interests  => {24713 => "true"}
     })

不确定我错过了什么。 任何指针都会有所帮助。 TIA

2 个答案:

答案 0 :(得分:1)

以下是典型配置的2个示例:

mailchimp1.lists.subscribe({:id => ENV["MAILCHIMP_LIST_ID"], 
                            :email => {:email => user.email}, 
                            :merge_vars => {:FNAME => user.first_name, :LNAME => user.last_name}, 
                            :double_optin => false})

mailchimp1.lists.subscribe(MAIL_CHIMP_LIST_ID,
                           # The email field is a struct that can use an
                           #    email address or two MailChimp specific list ids (see API docs)
                           {email: user.email},
                           # Set your merge vars here
                           {'FNAME' => user.first_name, 'LNAME' => user.last_name})

答案 1 :(得分:0)

试试这个:

def create_app():
       app = Flask(__name__)
       return app

如果您可以使用此功能,则可以在此引用后添加其他参数:

https://www.rubydoc.info/gems/mailchimp-api/2.0.4/Mailchimp/Lists#subscribe-instance_method