2016-07-27 15 views
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 
    }; 

答えて

1

Mailgun APIで述べたように、bouncedイベントは、私が見ていたbodyフィールド

+0

おかげ含まれていません。私が上で行ったように、他の方法で私は身体を解析する以外に解析することができます。 – Jayanth

関連する問題