gpt4 book ai didi

c# - 获取所有列表成员 - MailChimp 3.0

转载 作者:太空宇宙 更新时间:2023-11-03 16:59:56 31 4
gpt4 key购买 nike

我正在尝试获取列表中的所有成员(大约 19,000 名成员)并使用 Mailchimp.NET.V3在 C# 中打包。

以下代码仅检索前 1000 个成员

IMailChimpManager MC = new MailChimpManager(@"xxxxxxxxxxxxxxxxxxxxxxxxx-xxx");
var listMembers = await MC.Members.GetAllAsync(ListId);

我也尝试过使用 MemberRequest 构造函数,但这从不返回任何值。

var listMembers = await MC.Members.GetAllAsync(ListId, new MemberRequest { Limit = 20000 } );

有人可以帮忙吗?谢谢!

最佳答案

使用偏移值。

List<Member> listMembers = new List<Member>();
IMailChimpManager manager = new MailChimpManager(MailChimpApiKey);
bool moreAvailable = true;
int offset = 0;
while (moreAvailable)
{
var listMembers = manager.Members.GetAllAsync(yourListId, new MemberRequest
{
Status = Status.Subscribed,
Limit = 250,
Offset = offset
}).ConfigureAwait(false);

var Allmembers = listMembers.GetAwaiter().GetResult();
foreach(Member member in Allmembers)
{
listMembers.Add(member);
}
if (Allmembers.Count() == 250)
//if the count is < of 250 then it means that there aren't more results
offset += 250;
else
moreAvailable = false;
}

关于c# - 获取所有列表成员 - MailChimp 3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42965441/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com