在Mailchimp官方文档中,以python为例
from mailchimp_marketing import Client
mailchimp = Client()
mailchimp.set_config({
"api_key": "YOUR_API_KEY",
"server": "YOUR_SERVER_PREFIX"
})
response = mailchimp.ping.get()
print(response)
这个api_key字段我们应该从后台管理取,示例如下
image.png
image.png
image.png
关于server取值,如果我们设置为空字符串或None
mailchimp.set_config({
"api_key": "11112222-us20",
"server": ""
})
也会依旧有默认的服务器前缀server,会报以下错误
An exception occurred: HTTPSConnectionPool(host='server.api.mailchimp.com', port=443): Max retries exceeded with url: /3.0/lists/568701b131/members/268ade76e18fd3f0cc1a218f162a06ae/tags (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_
正确情况如果我们使用,应该去掉server字段。
mailchimp.set_config({
"api_key": "11112222-us20"
})
或者 server字段取名如下 (取api_key的后缀)
mailchimp.set_config({
"api_key": "11112222-us20",
"server": "us20"
})
网友评论