0

我用 rails 3.2 和 ruby​​ 2.1.2 创建了一个 rails 应用程序。我使用长臂猿 gem来访问邮件黑猩猩 API 以创建/编辑/删除邮件黑猩猩列表以及管理订阅者。我无法使用长臂猿提供的方法创建新的黑猩猩邮件列表。但我能够获得已经创建的(邮件黑猩猩网络应用程序中的默认列表)列表。我想知道如何创建邮件黑猩猩列表。我在 github 页面中没有找到相同的示例。

4

1 回答 1

1

最终我得到了解决方案。我可以使用 Gibbon 2.2.4 使用以下代码创建邮件黑猩猩列表。

gibbon = Gibbon::Request.new()
params = {
    "name" => name,
    "contact" => {
        "company" => "Your Company",
        "address1" => "address one",
        "address2" => "address two",
        "city" => "city",
        "state" => "state",
        "zip" => "zip-code",
        "country" => "country name",
        "phone" => "phone"
    },
    "permission_reminder" => "You are receiving this email, because you subscribed our product.",
    "campaign_defaults" => {
        "from_name" => "Test user",
        "from_email" => "testuser@test.com",
        "subject" => "",
        "language" => "en"
    },
    "email_type_option" => true
}

mail_chimp_list = gibbon.lists.create(body: params)

我的 gibbon.rb 文件看起来像

Gibbon::Request.api_endpoint = "https://****.api.mailchimp.com"
Gibbon::Request.api_key = "api-key"
Gibbon::Request.timeout = 15
于 2016-11-21T05:46:58.857 回答