我正在 nodejs 中创建一个应用程序来使用 MailChimp 发送电子邮件。我尝试过使用https://apidocs.mailchimp.com/sts/1.0/sendemail.func.php https://apidocs.mailchimp.com/sts/1.0/sendemail.func.php但将其更改为使用 3.0 api,因为 1.0 似乎不再起作用(大惊喜)。我已经设置了我的应用程序
var apiKey = '<<apiKey>>',
toEmail = '<<emailAddress>>',
toNames = '<<myName>>',
message = {
'html': 'Yo, this is the <b>html</b> portion',
'text': 'Yo, this is the *text* portion',
'subject': 'This is the subject',
'from_name': 'Me!',
'from_email': '',
'to_email': toEmail,
'to_name': toNames
},
tags = ['HelloWorld'],
params = {
'apikey': apiKey,
'message': message,
'track_opens': true,
'track_clicks': false,
'tags': tags
},
url = 'https://us13.api.mailchimp.com/3.0/SendEmail';
needle.post(url, params, function(err, headers) {
if (err) {
console.error(err);
}
console.log(headers);
}
});
我不断收到 401 响应(未授权,因为我没有正确发送 API 密钥)
由于服务器的限制,我必须使用needle。