6
mailgun의 webhook을 탭하여 meteorjs에서 데이터를 수신하려고합니다. Router
에서 이벤트를 처리 중이지만 bounced
이벤트 중에는 req.body
에서 아무것도 찾을 수 없습니다.MeteorJS Mailgun Webhook Bounced 이벤트
Router.route('/api/v1/mailgun/hooks',{ where: 'server' })
.post(function() {
Router.onBeforeAction(Iron.Router.bodyParser.urlencoded({
extended: false
}));
this.response.setHeader('access-control-allow-origin', 'mailgun.com');
var req = this.request;
var res = this.response;
var values = req;
res.end('Well this is the end');
// console.log('The event is ', values);
var campaignId, campaignId1, recipient, message_id, timestamp, domain, city, client_name, client_os, client_type,
country, device_type, user_agent, ip_address, url = '',event;
if (values.event == 'delivered') {
//Key Values
domain = values['domain'];
event = values['event'];
t_camp = values['X-Mailgun-Tag'];
campaignId = t_camp.split(":")[1];
message_id = values['Message-Id'];
recipient = values['recipient'];
timestamp = values['timestamp'];
//Key Values
}
if (values.event == 'opened' || values.event == 'clicked') {
//Key Values
domain = values['domain'];
event = values['event'];
t_camp = values['tag'];
campaignId = t_camp.split(":")[1];
message_id = values['message-id'];
recipient = values['recipient'];
timestamp = values['timestamp'];
//Key Values
city = values['city'];
ip_address = values['ip'];
client_name = values['client-name'];
client_os = values['client-os'];
client_type = values['client-type'];
country = values['country'];
device_type = values['device-type'];
user_agent = values['user-agent'];
}
if (values.event == 'clicked') {
url = values['url'];
}
// if (values.event == 'unsubscribed' || values.event == 'bounced' || values.event == 'dropped' || values.event == 'rejected' || values.event == 'failed') {
if (values.event == 'rejected' || values.event == 'failed') {
//Key Values
domain = values['domain'];
event = values['event'];
t_camp = values['tag'];
campaignId = t_camp.split(":")[1];
message_id = values['message-id'];
recipient = values['recipient'];
timestamp = values['timestamp'];
//Key Values
city = values['city'];
ip_address = values['ip'];
client_name = values['client-name'];
client_os = values['client-os'];
client_type = values['client-type'];
country = values['country'];
device_type = values['device-type'];
user_agent = values['user-agent'];
}
data = {
'domain': domain,
'event': event,
'campaign': campaignId,
'message': message_id,
'recipient': recipient,
'timestamp': timestamp,
'city': city,
'ip_address': ip_address,
'client_name': client_name,
'client_os': client_os,
'client_type': client_type,
'country': country,
'device_type': device_type,
'user_agent': user_agent,
'url': url
};
감사를 포함하지 않는다 :
다음은 내 코드입니다. 위에서 한 것처럼 몸을 파싱하는 것 외에는 다른 방법으로 파싱 할 수 있습니다. – Jayanth