Ruby on rails 如何使用ruby使用mailchimp模板?
我想用Ruby和mailchimp templetes一起工作。 我安装了gem mailchimp api并尝试了以下方法:Ruby on rails 如何使用ruby使用mailchimp模板?,ruby-on-rails,ruby,mailchimp,gibbon,Ruby On Rails,Ruby,Mailchimp,Gibbon,我想用Ruby和mailchimp templetes一起工作。 我安装了gem mailchimp api并尝试了以下方法: mailchimp = Mailchimp::API.new(ENV['MAILCHIMP_API_KEY']) lists = mailchimp.templates.list list = lists['data'] puts list gibbon = Gibbon::Request.new(api_key: ENV['MAILCHIMP_API_KEY'])
mailchimp = Mailchimp::API.new(ENV['MAILCHIMP_API_KEY'])
lists = mailchimp.templates.list
list = lists['data']
puts list
gibbon = Gibbon::Request.new(api_key: ENV['MAILCHIMP_API_KEY'])
templates = gibbon.templates.retrieve(params: {type: 'user'})
templates['templates'].each do |template|
if template['name'] == 'my_template'
id = template['id']
它返回lists=Hash 3个元素:“user'=空数组,'gallery'=空数组,'base'=空数组,结果list=nil
我安装了gem gibbon并尝试了以下方法:
mailchimp = Mailchimp::API.new(ENV['MAILCHIMP_API_KEY'])
lists = mailchimp.templates.list
list = lists['data']
puts list
gibbon = Gibbon::Request.new(api_key: ENV['MAILCHIMP_API_KEY'])
templates = gibbon.templates.retrieve(params: {type: 'user'})
templates['templates'].each do |template|
if template['name'] == 'my_template'
id = template['id']
我得到了模板id,但是gibbon.templates.infotemplate\u id:id返回@api\u endpoint=nil。如何接收模板源并使用它
非常感谢。不太清楚,但也许您应该使用retrieve按id查找模板。 差不多
gibbon.templates.retrieve(params: { template_id: your_id_here })
根据。我不知道确切情况,但也许您应该使用retrieve按id查找模板。 差不多
gibbon.templates.retrieve(params: { template_id: your_id_here })
根据。我找到了解决办法。Mailchimp帐户可以与mandrill帐户链接以发送事务性邮件。解决方案是将模板从mailchimp克隆到mandrill,并使用mandrill api gem加载模板体,如下所示:
mandrill = Mandrill::API.new(ENV["SMTP_PASSWORD"])
body = mandrill.templates.render(template_name, [], vars )["html"]
我找到了解决办法。Mailchimp帐户可以与mandrill帐户链接以发送事务性邮件。解决方案是将模板从mailchimp克隆到mandrill,并使用mandrill api gem加载模板体,如下所示:
mandrill = Mandrill::API.new(ENV["SMTP_PASSWORD"])
body = mandrill.templates.render(template_name, [], vars )["html"]
它从所有模板中返回前10个模板,gibbon呢。模板这里是你的id。检索?当然可以,但这与我的循环模板中的模板['templates']相同。如果模板['name']=='my_template'返回true,则每个模板都会返回。我没有找到关于如何在Ruby中使用模板的示例。我的意思是关于如何使用模板源等等的示例。请尝试调试。你需要看看r.body包含什么。这就是你的列表所包含的内容。它从所有模板中返回前10个模板,gibbon呢。模板在这里是你的id。检索?当然可以,但这与我的循环模板中的模板['templates']相同。如果模板['name']='my_template'返回true,则每个模板都会返回。我没有找到关于如何在Ruby中使用模板的示例。我的意思是关于如何使用模板源等等的示例。请尝试调试。你需要看看r.body包含什么。这就是您的列表所包含的内容。