【问题标题】:Ruby integration with mailchimp-api gemRuby 与 mailchimp-api gem 的集成
【发布时间】:2015-01-08 07:41:37
【问题描述】:

我正在尝试使用 RoR 和官方 mailchimp-api gem 将一封电子邮件订阅到多个列表。它有效,但最后四个值(double_optin、update_existing、replace_interests 和 send_welcome)没有更新,即使我试图将 update_existing 传递为 true,我也会收到电子邮件“已经存在”的错误。我已经多次写信给 Mailchimp,他们觉得他们已经到了帮助的尽头。他们说他们不是包装专家——即使它是“官方”宝石——也无法进一步帮助我。我的代码如下所示:

  responses << mailchimp_lists.each do |ml|
    mailchimp.lists.subscribe(
      ml,
      { "email" => order.customer_email,
        "euid" => order.customer_id,
        "leid" => ""
      },
      { "FNAME"       => order.customer_first_name,
        "LNAME"       => order.customer_last_name,
        "COMPANY"     => order.company_name,
        "ADDRESS1"    => order.billing_address_1,
        "ADDRESS2"    => order.billing_address_2,
        "CITY"        => order.billing_city,
        "STATE"       => order.billing_state,
        "POSTALCODE"  => order.billing_zip,
        "SALUTATION"  => ""
      },
      "html",
      false,
      true,
      false,
      false
      )
  end

我尝试过以几种不同的方式发送最后四个参数,例如:

      "email_type" => "html",
      "double_optin" => false,

或者:

      {"email_type" => "html"},
      {"double_optin" => false}

有时,Mailchimp 可以看到参数到达的方式似乎不应该触发“电子邮件已存在”错误,但它只是不起作用。任何帮助表示赞赏。

【问题讨论】:

    标签: ruby-on-rails-3 mailchimp


    【解决方案1】:

    mailchimp-api gem 的文档将订阅方法描述为:

    #subscribe(id, email, merge_vars = nil, email_type = 'html', double_optin = true, update_existing = false, replace_interests = true, send_welcome = false)
    

    虽然 batch_subscribe 显示:

    #batch_subscribe(id, batch, double_optin = true, update_existing = false, replace_interests = true)
    

    请注意,批处理方法不包含“send_welcome”参数。当我从订阅方法的参数列表中删除它时——基本上发送三个布尔值而不是建议的四个布尔值,update_existing 工作得很好。这里的文档中似乎有一个错误:http://www.rubydoc.info/gems/mailchimp-api/2.0.4/Mailchimp/Lists#subscribe-instance_method

    希望这对其他人有帮助!

    【讨论】:

      猜你喜欢
      • 2013-02-20
      • 2013-11-11
      • 1970-01-01
      • 2014-07-14
      • 2016-06-01
      • 2016-01-10
      • 2021-02-25
      • 2021-07-16
      • 2020-12-18
      相关资源
      最近更新 更多