C# 。 net获得列表的活跃订阅者(活动监视器)

时间:2017-03-02 10:09:14

标签: campaign-monitor

我是CM API的新用户并且正在使用.net库。在下面的代码中,我循环遍历帐户中的每个客户端,然后是客户端下的每个列表。这工作正常。对于下一步,我想循环遍历每个列表中的活跃订阅者,但我被困在那里,

AuthenticationDetails auth = new ApiKeyAuthenticationDetails("3efa70e3918fc3e6282eb2ef053a9b0c29247f180e78d8b1");
var general = new General(auth);
var clients = general.Clients();
foreach (BasicClient c in clients)
{
 var clientID = c.ClientID;
 var cl = new Client(auth, c.ClientID);
 var list = cl.Lists();
 Console.WriteLine(string.Format("----------List Details-------------"));
  var ListID = "";
            foreach (var listItem in list)
            {
                ListID = listItem.ListID;
                Console.WriteLine("\n");
                Console.WriteLine(string.Format("List ID  - {0}", listItem.ListID));
                Console.WriteLine(string.Format("List Name  - {0}", listItem.Name));

                ListDetail details = cl.HttpGet<ListDetail>(
                string.Format("/lists/{0}.json", ListID), null);


                Console.WriteLine(string.Format("ConfirmationSuccessPage  - {0}", details.ConfirmationSuccessPage));
                Console.WriteLine(string.Format("ConfirmedOptIn  - {0}", details.ConfirmedOptIn));
                Console.WriteLine(string.Format("UnsubscribePage  - {0}", details.UnsubscribePage));
                Console.WriteLine(string.Format("UnsubscribeSetting  - {0}", details.UnsubscribeSetting));

                ListStats Liststats = cl.HttpGet<ListStats>(string.Format("/lists/{0}/stats.json", ListID), null);
                Console.WriteLine(string.Format("Total Active Subscribers - {0}", Liststats.TotalActiveSubscribers));


            }
}

1 个答案:

答案 0 :(得分:0)

ListDetail details = cl.HttpGet<ListDetail>(
string.Format("/lists/{0}/active.json", ListID), null);