我想通过mailchimp发送电子邮件通知。
我阅读了文档并编写了一些代码,以便使用api.lists
获取列表:
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'mailchimp'
@options = ["list_id" => "$list_id", "subject" => "test subject", "from_name" => "test name", "from_email" => "info@example.com"]
@content = ["html" => "<p> test content </p>"]
@type = 'regular'
@title = 'Test Newsletter Title'
api = Mailchimp::API.new("key")
puts "Your lists:"
api.lists['data'].each do |list|
puts "\t #{list['name']}"
end
campaignCreate: 我创建了一个这样的广告系列:
api.campaignCreate(@type, @title, @content)
当我使用上述内容制作广告系列时,我收到以下错误:wrong number of arguments (4 for 2)
我想发送通知电子邮件。我怎么能这样做?
答案 0 :(得分:0)
我使用此
完成了 $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'mailchimp'
api = Mailchimp::API.new("api-key")
@content = {"html"=>"<p> test content </p>","text"=> "test"}
api.lists['data'].each do |list|
@options = {"list_id"=> list['id'], "subject"=>"test subject", "from_name"=>"test name", "from_email"=>"xyz@test.net", "template_id" => "xxxx"}
campaign = api.campaignCreate({"type"=>"regular", "options" => @options, "content"=> @content})
api.campaignSendNow({"cid" => campaign})
end