到目前为止,我已经使用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());
}
}
}
答案 0 :(得分:0)
好像你应该添加
client.execute(send);
之后
CampaignActionMethod.Send send = new CampaignActionMethod.Send(listId);