无法让合并标签工作 - Mandrill/Parse
Posted
技术标签:
【中文标题】无法让合并标签工作 - Mandrill/Parse【英文标题】:Can't get merge tags to work - Mandrill/Parse 【发布时间】:2015-01-11 08:24:20 【问题描述】:这是我的 Parse Cloud Code 调用:
Mandrill.sendTemplate(
"template_name": "start-conversation",
"template_content": [
"name": "example name",
"content": "example content" //Those are required but they are ignored
],
"message":
"to": [
"email": request.params.toUserEmail,
"name": request.params.toUserName
],
"important": true,
"merge": true,
"global_merge_vars": [
"rcpt": request.params.toUserEmail,
"vars": [
"name": "TOUSERNAME",
"content": request.params.toUserName
,
"name": "FROMUSERNAME",
"content": request.params.fromUserName
,
"name": "TOPICNAME",
"content": request.params.topicName
,
"name": "LANGUAGE",
"content": request.params.language
]
],
,
"async": true
,
success: function(httpResponse)
console.log(httpResponse);
response.success("mandrillStartConvoRequest -- success -- Email sent!");
,
error: function(httpResponse)
console.error(httpResponse);
response.error("mandrillStartConvoRequest -- error -- Uh oh, something went wrong");
);
这是<span>
,带有我的 Mandrill 模板中的标签:
<span style="line-height:20.7999992370605px">
*|TOUSERNAME|*
<br><br>
*|FROMUSERNAME|* would like to start a conversation with you about *|TOPICNAME|* in *|LANGUAGE|* </span>
邮件发送正常但没有合并 =(:
【问题讨论】:
【参考方案1】:据我所知,内置的 Mandrill.sendTemplate 方法不起作用。 所以你应该尝试自己调用 mandrill API,只需做一个 HTTP POST
https://parse.com/questions/send-mandrill-template-email-from-cloud-code-example-code-required
更新: 我在我的项目中使用的是这样的,注意我使用的是 merge_vars 但你使用的是 global_merge_vars
var params =
key: "xxxxxxxxxxxx",
template_name: "$template_name",
template_content: [],
message:
to: [
email: email
],
merge_vars : [
rcpt: email,
vars:[
"name" : "from",
"content" : "Test"
]
]
,
async: true
;
Parse.Cloud.httpRequest(
method: "POST",
headers:
"Content-Type": "application/json",
,
url: "https://mandrillapp.com/api/1.0/messages/send-template.json",
body: params,
success: function(httpResponse)
response.success("email sent");
,
error: function(httpResponse)
console.error(httpResponse);
response.error("Uh oh, something went wrong");
);
【讨论】:
试过了,它没有合并。同样的问题。 实际上,这行得通!一定是我 4 分钟前看到的一封延迟的电子邮件。 ~谢谢。以上是关于无法让合并标签工作 - Mandrill/Parse的主要内容,如果未能解决你的问题,请参考以下文章
无法让 UITableViewAutomaticDimension 正常工作