【发布时间】:2011-09-17 03:20:52
【问题描述】:
我需要在MailChimp.com 中创建并立即发送活动。我为此使用了 C# wrapper <strong>Percepective MCAPI.dll</strong>。
来自MailChimp API,很明显我们不能列出但可以创建活动。我尝试了代码,但 <strong>campaignID is retured null</strong>;至少没有抛出异常。我确实设置了campaigntype to Auto。
这是我的代码 sn-p:
尝试 { 字符串 apiKey = "api-us2"; // API KEY 有效 字符串 emailAddress = "ravinderpal.singh@abc.net"; listsForEmailInput lstForEmailInput = new listsForEmailInput(apiKey, emailAddress); listsForEmail cmd = 新的 listsForEmail(lstForEmailInput); listsForEmailOutput lstEmailOutPut = cmd.Execute(); 列出 lstResults = lstEmailOutPut.result; 字符串列表 ID = lstResults[0]; // 得到 Precraeted List ID( Valid Confirmed ) Console.WriteLine("\n" + listID); // 竞争创建 campaignCreateOptionscampaignCreateOpt = 新的campaignCreateOptions(); campaignCreateOpt.list_id = listID; campaignCreateOpt.subject = "来自 dev_Anil 的新广告系列"; campaignCreateOpt.from_email = "anil.k@abc.net"; campaignCreateOpt.from_name = "anil"; 字典内容 = new Dictionary(); content.Add("html", "Helloaasdsa"); content.Add("text", "大家好!!这是dev_anil"); content.Add("url", ""); content.Add("存档", ""); campaignSegmentOptions csOptions = 新的campaignSegmentOptions(); csOptions.match = "任何"; // 无法设置条件 - 需要帮助 // 需要设置一个 Dictionary typeOptions 因为不支持 null 字典 typeOptions = new Dictionary(); campaignCreateParmscampaignCreateParms = newcampaignCreateParms(apiKey, EnumValues.campaign_type.auto,campaignCreateOpt, content, csOptions, typeOptions); campaignCreateInputcampaignCreateInput = newcampaignCreateInput(campaignCreateParms); 活动创建活动创建 = 新活动创建(活动创建输入); campaignCreateOutput ccOutput =campaignCreate.Execute(campaignCreateInput); 字符串 abc = ccOutput.result; // 结果为 null } 捕获(异常 ee) { Console.WriteLine("\n\n 异常:" + ee.Message); // 没有例外 }谁能告诉我正确的方向和代码有什么问题。
任何帮助将不胜感激。
谢谢。
【问题讨论】: