使用maleorang v3.0 java api发送mailchimp活动
Posted
技术标签:
【中文标题】使用maleorang v3.0 java api发送mailchimp活动【英文标题】:sending mailchimp campaign with maleorang v3.0 java api 【发布时间】:2017-09-01 02:23:45 【问题描述】:到目前为止,我已经可以使用 java 类在 mailchimp 中的活动列表中创建一个新活动,但是,我无法发送它,查看代码,有人有建议吗?
它执行活动的创建(我在 mailchimp 中看到它),我收到了campaignInfo 对象,但从发送这个活动的角度来看,我无法弄清楚
package mailingapp2;
import com.ecwid.maleorang.MailchimpClient;
import com.ecwid.maleorang.method.v3_0.campaigns.CampaignActionMethod;
import com.ecwid.maleorang.method.v3_0.campaigns.CampaignInfo;
import com.ecwid.maleorang.method.v3_0.campaigns.CampaignInfo.SettingsInfo;
import static com.ecwid.maleorang.method.v3_0.campaigns.CampaignInfo.Type.PLAINTEXT;
import com.ecwid.maleorang.method.v3_0.campaigns.EditCampaignMethod;
public class SendMailchimpCampaign
public void SendCampaign() throws Exception
String apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
String listId = "d069f8c902";
String Email ="test@test.be";
String firstName = "test";
String lastName = "test";
MailchimpClient client = new MailchimpClient(apiKey);
try
EditCampaignMethod.Create method = new EditCampaignMethod.Create();
method.type = PLAINTEXT;
method.settings = new SettingsInfo();
method.settings.mapping.put("title", "test2");
method.settings.mapping.put("subject_line", "test");
method.settings.mapping.put("from_name", "test");
method.settings.mapping.put("reply_to", "info@test.be");
CampaignInfo campaign = client.execute(method); //until here it works, //it executes, and I receive back the campaignInfo object, but from here I can't //figure it out how to move on to send this campaign.
CampaignActionMethod.Send send = new CampaignActionMethod.Send(listId);
System.out.println("info" + campaign);
catch (Exception e)
System.err.println("Caught IOException: " + e.getMessage());
【问题讨论】:
【参考方案1】:看来你应该添加
client.execute(send);
紧接着
CampaignActionMethod.Send send = new CampaignActionMethod.Send(listId);
【讨论】:
您好,我已经添加了这样的内容,他尝试执行,(listId 应该是 CampaignId)我已经能够添加 list_idRecipientsInfo r = new RecipientsInfo(); r.list_id="xxxxxxxxxx"; r.list_name="testlijst";method.recipients = r;
但现在我正在努力处理内容,如何放置它们在。
对于谁感兴趣,这就是我放置内容并发送的方式SetCampaignContentMethod sccm = new SetCampaignContentMethod(campaign.id); sccm.plain_text = "Dit is een testbericht"; client.execute(sccm); CampaignActionMethod.Send send = new CampaignActionMethod.Send(campaign.id); client.execute(send);
以上是关于使用maleorang v3.0 java api发送mailchimp活动的主要内容,如果未能解决你的问题,请参考以下文章
使用 MailChimp API v3.0 创建新的订阅者验证错误
使用 Mailchimp api v3.0 将订阅者添加到分段