我试图向mailchimp发出http请求以添加订阅者,但我似乎收到了403禁止的错误。我已经联系了Mailchimp,这似乎是Parse的一个问题。有没有人遇到过类似的问题?如果是这样,你解决了吗?这是我的云功能:
注意:我使用的是Mailchimp的最新API(大约一周前它也能顺利运行):
Parse.Cloud.define("reserveSpot", function(request, response) {
//Check that parameters are being provided
if (!request.params || !request.params.emailAddress || !request.params.firstName || !request.params.lastName) {
//Return Response
response.error("In order to save you a spot we're gonna need your name and email address.");
return;
}
//Retrieve Parameters
var firstName = request.params.firstName;
var lastName = request.params.lastName;
var emailAddress = request.params.emailAddress;
var inviter = request.params.inviter;
var recruiter = request.params.recruiter;
//Define Subscriber
var subscriber = JSON.stringify({
"email_address": emailAddress,
"status": "subscribed",
"merge_fields": {
"FNAME": firstName,
"LNAME": lastName,
"INVITER": inviter,
"RECRUITER": recruiter
}
});
//Create POST Request
Parse.Cloud.httpRequest({
method: 'POST',
url: 'https://us13.api.mailchimp.com/3.0/lists/<listID>/members',
body: subscriber,
headers:
{
'Authorization': 'apikey XXXXXXXX',
'Content-Type': 'application/json'
}
}).then(function(httpResponse) {
//Log Data
console.log("Success: " + httpResponse.text);
response.success(httpResponse.text);
}, function(httpResponse) {
//Log Error
console.error('Full Error: ' + JSON.stringify(httpResponse));
//Return Response
response.error(httpResponse.text);
});
});