null104无效的MailChimp"无效的MailChimp API密钥:xxxx .."

时间:2016-01-15 10:40:32

标签: asp.net mailchimp

我正在尝试使用此代码在ASP.NET中使用MailChimp API创建新广告系列

public  string CreateCampaignAndSend(string apiKey, string listID)
    {
        Int32 TemplateID = 100;
        string campaignID = string.Empty;

        MailChimpManager mc = new MailChimpManager("sampleAPIKeyXXXXXXXXXXXXXX-us12");

        // compaign Create Options

        campaignCreateOptions campaignCreateOpt = new campaignCreateOptions();
        campaignCreateOpt.list_id = listID;
        campaignCreateOpt.subject = "subject";
        campaignCreateOpt.from_email = "wisdomthnkrs@gmail.com";
        campaignCreateOpt.from_name = "abc";
        campaignCreateOpt.template_id = TemplateID;

        campaignCreateOpt.authenticate = true;
        campaignCreateOpt.auto_footer = false;
        campaignCreateOpt.tracking.opens = true;
        campaignCreateOpt.tracking.html_clicks = true;
        campaignCreateOpt.tracking.text_clicks = true;

        // Content

        Dictionary<string, string> content = new Dictionary<string, string>();
        content.Add("html_ArticleTitle1", "ArticleTitle1");
        content.Add("html_ArticleTitle2", "ArticleTitle2");
        content.Add("html_ArticleTitle3", "ArticleTitle3");
        content.Add("html_Article1", "Article1");
        content.Add("html_Article2", "Article2");

        //Conditions
        List<campaignSegmentCondition> csCondition = new List<campaignSegmentCondition>();
        campaignSegmentCondition csC = new campaignSegmentCondition();

        csC.field = "interests-" + 123; // where 123 is the Grouping Id from listInterestGroupings()
        csC.op = "all";
        csC.value = "";
        csCondition.Add(csC);

        // Options
        campaignSegmentOptions csOptions = new campaignSegmentOptions();
        csOptions.match = "all";


        // Type Options
        Dictionary<string, string> typeOptions = new Dictionary<string, string>();
        typeOptions.Add("offset-units", "days");
        typeOptions.Add("offset-time", "0");
        typeOptions.Add("offset-dir", "after");

        // Create Campaigns
        campaignCreateParms campaignCreateParms = new campaignCreateParms(mc.APIKey, EnumValues.campaign_type.regular, campaignCreateOpt, content, csOptions, typeOptions);
        campaignCreateInput campCreateInput = new campaignCreateInput(campaignCreateParms);

        campaignCreate campaignCreate = new campaignCreate(campCreateInput);
        //xyz();
        //string abc = xxxxxxxxxxxxxxxxx;
        campaignCreateOutput ccOutput = campaignCreate.Execute(campCreateInput);

        List<Api_Error> error = ccOutput.api_ErrorMessages;  // Catching API Errors
        string s = "null";

        if (error.Count <= 0)
        {
            campaignID = ccOutput.result;

        }
        else
        {
            foreach (Api_Error ae in error)
            {
                Console.WriteLine("\n ERROR Creating Campaign : ERRORCODE\t:" + ae.code + "\t ERROR\t:" + ae.error);
                s = s + ae.code;
                s = s + ae.error;
            }
        }
        return s;
    }

但在我给出正确的密钥时显示错误。 这是错误,

  

null104无效的MailChimp&#34;无效的MailChimp API密钥:   6ea29f158xxxxxxxxxxxx&#34;

0 个答案:

没有答案