0

我想通过 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)

我想发送通知电子邮件。我怎样才能做到这一点?

4

1 回答 1

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
于 2012-12-03T07:40:26.370 回答