基于https://www.plivo.com/blog/Send-templatized-SMS-from-a-Google-spreadsheet-using-Plivo-SMS-API/我有以下代码:
data = {
"SOURCE" : "+1234567890",
"DESTINATION" : "+2345678901",
"FIRST_NAME" : "Jane",
"LAST_NAME" : "Doe",
"COUPON" : "DUMMY20",
"STORE" : "PLIVO",
"DISCOUNT" : "20",
}
template_data = "Hi FIRST_NAME , your coupon code for discount of % purchase at is "
function createMessage(data,template_data){
Logger.log(data);
for (var key in data) {
Logger.log(key);
if (data.hasOwnProperty(key)) {
template_data = template_data.replace(new RegExp('+key+', 'gi'), data[key]);
}
}
Logger.log(template_data);
return template_data;
}
当我运行createMessage
并检查日志时,我看到:
[18-10-02 13:19:03:139 EDT] undefined
[18-10-02 13:19:03:139 EDT] undefined
这向我表明参数没有被传递到函数中。我究竟做错了什么?