2016-03-22 10 views
0

私のアプリケーション(Devise)にサインアップするとすぐにユーザーの名前と電子メールを自動的にMailchimpアカウントに送信するにはどうすればよいですか?後フックMailchimpへのユーザー情報の自動送信

class User < ActiveRecord::Base 
    after_create :send_to_mailchimp 

    def send_to_mailchimp 
    # send data to mailchimp 
    end 
end 

答えて

1

を作成するには、おそらく通常のユーザーを使用する必要があります

1

私は彼らのAPIを使用して

def add_to_mailchimp(email_address, first_name, last_name) 
    list_id = "your_list_id" 
    gibbon = Gibbon::Request.new 
    # only need the md5_email if you want to use 'upsert' (find_or_create_by) or 'update', not 'create' 
    md5_email = Digest::MD5.hexdigest(email_address) 

    gibbon.lists(list_id).members(md5_email).upsert(body: {email_address: email_address, status: "subscribed", merge_fields: {FNAME: first_name, LNAME: last_name}}) 
    end 
を仕事に Gibbon、mailchimpラッパーを使用したいです
関連する問題