我正在编写一个脚本,该脚本需要google工作表数据并上传我的mailchimp订阅者数据,其中编辑的单元格值作为更新的合并标记发送。原始代码来自here。我已经成功运行了脚本,接受了这一个错误:
"Invalid Resource","status":400,"detail":"Blank email address"
我根据mailchimp api文档中的文档理解错误,但我不确定为什么它不能识别脚本中的订阅者数据:
var emHash = md5(em.toLowerCase()); //this is pulled from my md5 function
var payload = JSON.stringify({
"status_if_new": "subscribed",
"email_address": em,
"merge_fields": {
"LEAD": lead,
//rest of vars following same syntax
}
});
var options = {
"headers" : headers,
"payload": payload,
"method" : "put",
"muteHttpExceptions" : true
};
var response = UrlFetchApp.fetch('https://us15.api.mailchimp.com/3.0' + '/lists/' + 'xxxxxxx' + '/members/' + emHash,options);
Logger.log(response);
}
最后是通过编辑触发的功能,以便通过上面的函数发送更改的值
function onEdit(e) {
var activeSheet = e.source.getActiveSheet();
var range = e.range;
var rowedited = range.getRowIndex();
if (activeSheet.getName() !== "ATTENDANCE"){
return;
Logger.log("Oops :(");
}
else {
var values = sheet.getRange(rowedited, 1, 1, 13).getValues()[0];
var em = values[2];
var lead = values[1];
//remaining vars omitted for brevity
sendToMailChimp_(em,lead...[etc.]);
}
有什么想法吗?
答案 0 :(得分:0)
我想通了 - 我拉了一个业余的动作并将列归因于错误的数组元素......所以是的,我从1开始而不是0
捂脸
现在正在运作!