3

MailChimp アカウントからリストとそのグループを取得し、PerceptiveMCAPI を使用して複数のグループにユーザーをサブスクライブするために、次のコードを作成しました。問題なくグループに登録できますが、特定のグループからユーザーを削除することはできません。listUpdateMember と update_existing プロパティの両方を使用してみましたが、何も機能しませんでした。

コードは次のとおりです。

public partial class Signup : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            this.GetList();
        }

    }

    protected void btnSubscribe_Click(object sender, EventArgs e)
    {
        Dictionary<string, object> dic = new Dictionary<string, object>();
        List<interestGroupings> lst = new List<interestGroupings>();           
        for (int i = 0; i <= chkGroups.Items.Count - 1;i++ )
        {
            if (chkGroups.Items[i].Selected)
            {
                lst.Add(new interestGroupings { id = Convert.ToInt32(chkGroups.Items[i].Value), name = chkGroups.Items[i].Text, groups = new List<string> { chkGroups.Items[i].Text } });
            }
        }
        dic.Add("GROUPINGS", lst);            

        listSubscribeParms param = new listSubscribeParms();
        param.email_address = txtEmail.Text;
        param.email_type = EnumValues.emailType.html;
        param.apikey = MCAPISettings.default_apikey;
        param.id = drpList.SelectedValue;
        param.merge_vars = dic;
        //param.update_existing = true;
        listSubscribeInput subInput = new listSubscribeInput(param);
        listSubscribe sub = new listSubscribe(subInput);
        listSubscribeOutput subOutput = sub.Execute();
        if (subOutput.result)
            Response.Write("Congrats! a confirmation email has been sent to your email id");
        else
        {
            listUpdateMemberParms upparam = new listUpdateMemberParms(MCAPISettings.default_apikey,param.id, param.email_address, param.merge_vars, EnumValues.emailType.html,true);
            this.UpdateMember(upparam);
        }
    }

    private void UpdateMember(listUpdateMemberParms param)
    {            
        listMemberInfoInput memInput = new listMemberInfoInput(MCAPISettings.default_apikey, param.id, param.email_address);
        listMemberInfo memInfo = new listMemberInfo();
        listMemberInfoOutput memOutput = memInfo.Execute(memInput);

        param.email_address = memOutput.result.id;
        param.replace_interests = true;

        listUpdateMemberInput upInput = new listUpdateMemberInput(param);
        listUpdateMember update = new listUpdateMember(upInput);
        listUpdateMemberOutput output = update.Execute();
        if (output.result)
            Response.Write("Congrats! your details has been updated");
        else
        {
            Response.Write("Sorry! it seems you already exist in our database.");
        }
    }

    private void GetList()
    {
        // Code to get the list and add it to Dropdown list
    }
    private void GetGroups()
    {
        //Code to get groups under a list and adding it to check box
    }       

}

私を助けてください。

よろしく、 アルル

4

0 に答える 0