我没有特定于 C# 的示例,但我认为这应该可以帮助您启动并运行。这是您需要的 SparkPost API
https://developers.sparkpost.com/api/suppression-list/
如果语言不是超级重要并且只是寻找拉列表的最简单方法,请查看此处:
https ://www.sparkpost.com/docs/tech-resources/download-suppression-list/
...或者我的朋友 tuck1s 在 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"
以下是您可以取消抑制的来源:
- 反弹规则
- 遵守
- 列出退订
- 手动添加
- 垃圾邮件投诉
- 退订链接
这将产生这样的结果
{
"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
}
要获取下一页结果,只需按照发送的 URI/links/href
这是 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);