从Sparkpost检索我的整个抑制列表



我希望有人能给我一些指导,也许一个例子。
我似乎找不到做这件事的方法。我需要使用c#从Sparkpost检索我的整个抑制列表。

我已经搜索过了,所有我发现的是API c#参考页面上的内容:

var client = new client (MY_API_KEY");

client.Suppressions.List ();//返回

的列表client.Suppressions。List(new {limit = 3});//它接受匿名类型的过滤器

client.Suppressions。列表(新SuppressionQuery ());//SuppressionQuery也允许输入帮助

但是它没有说明如何使用这个。有没有人在c#代码检索整个抑制列表?

提前感谢,山姆

我没有c#的具体例子,但我认为这应该让你开始运行。这是你需要的SparkPost APIhttps://developers.sparkpost.com/api/suppression-list/

如果语言不是很重要,只是在寻找最简单的方法来拉列表,看看这里:https://www.sparkpost.com/docs/tech-resources/download-suppression-list/

…或者我的朋友tuck15在Python中有一个很好的例子:https://github.com/tuck1s/sparkySuppress

您需要将$SPARKPOST_API_KEY更改为您的API密钥。

使用此命令获取抑制列表的摘要

curl -v -H "Content-Type: application/json" -H "Authorization: $SPARKPOST_API_KEY" -X GET "https://api.sparkpost.com/api/v1/suppression-list/summary"

你可以这样做来获得你的抑制列表记录

curl -v 
-H "Content-Type: application/json" 
-H "Authorization: $SPARKPOST_API_KEY" 
-X GET "https://api.sparkpost.com/api/v1/suppression-list?sources=Bounce+Rule,Manually+Added"

以下是您可以提取抑制的来源:

<
  • 反弹规则/gh>遵守
  • 列表
  • 手动添加
  • <
  • 垃圾邮件投诉/gh>
  • 退订链接

将产生如下结果

{
"results": [
{
"recipient": "jane@example.com",
"type": "transactional",
"source": "Manually Added",
"description": "MBL: jane@example.com,hard-bounce,"smtp;550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces. Learn more at https://support.google.com/mail/answer/",
"created": "2020-10-23T18:50:07+00:00",
"updated": "2020-10-23T18:50:07+00:00",
"transactional": true
},
{
"recipient": "john@example.com",
"type": "transactional",
"source": "Manually Added",
"description": "MBL: john@example.com,hard-bounce,"smtp;550 5.1.10 RESOLVER.ADR.RecipientNotFound; Recipient not found by SMTP address lookup","2015-12-18 17:49:49.74724","2016-01-28 19:44:39","2016-01-14 19:44:39.83638","2016-01-28 19:44:39",",
"created": "2020-10-23T18:50:07+00:00",
"updated": "2020-10-23T18:50:07+00:00",
"transactional": true
}
],
"links": [
{
"href": "/api/v1/suppression-list?page=2&sources=Bounce Rule,Manually Added&per_page=1000",
"rel": "next"
},
{
"href": "/api/v1/suppression-list?page=10&sources=Bounce Rule,Manually Added&per_page=1000",
"rel": "last"
}
],
"total_count": 1111578

}

要获得下一页的结果,只需遵循在/links/href

中发送的URI下面是PostMan为上面的Curl命令生成的c#示例

var client = new RestClient("https://api.sparkpost.com/api/v1/suppression-list?sources=Bounce+Rule,Manually+Added");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "SPARKPOST_API_KEY");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

相关内容

  • 没有找到相关文章

最新更新