2016-07-27 23 views
6

Mailgun web karesine dokunmaya çalışıyorum ve verileri meteorjs içinde almaya çalışıyorum. Olayı Router ile işliyorum, ancak bounced olay sırasında, req.body içinde hiçbir şey bulamıyorum.MeteorJS Mailgun Webhook Sıçrama Etkinliği

Mailgun API belirtildiği üzere
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 
    }; 

cevap

1

, bounced olay bir body sahadan bir göz var mı

+0

Teşekkür içermez:

Aşağıda benim kodudur. Yukarıda yaptığım gibi vücudu ayrıştırmaktan başka bir şekilde ayrışabilmem için. – Jayanth