2017-07-03 12 views
1

私はAmazon SES(シンプルメールサービス)メッセージをSNS(シンプル通知サービス)経由でhttpサーバー経由で処理しようとしています。Amazon SNS確認

しかし、ドメインを確認できません。これを行う正しい方法は何ですか?私は 'sns-validator' npmモジュールを試しましたが、彼はメッセージに必要なキーがないと言います。

ExpressでNode.JSを使用しています。検証メッセージを解析する正しい方法は何ですか?

validator.validate(req.headers, function (err, message) { 
     if (err) { 
      console.error(err); 
      return; 
     } 

     if (message['Type'] === 'SubscriptionConfirmation') { 
      https.get(message['SubscribeURL'], function (res) { 
      // You have confirmed your endpoint subscription 
      console.log("confirmed"); 
      }); 
     } 
    }); 

編集: 私はreqを記録していると私は、私は、データという見つけることができますhttp://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.html#SendMessageToHttp.prepare に加入して、私はデータを持っていないreq.headers

accept-encoding:"gzip,deflate" 
content-length:"1517" 
content-type:"text/plain; charset=UTF-8" 
host:"[nrgokurl].ngrok.io" 
user-agent:"Amazon Simple Notification Service Agent" 
x-amz-sns-message-id:"[id]" 
x-amz-sns-message-type:"SubscriptionConfirmation" 
x-amz-sns-topic-arn:"arn:[arn]:complaints" 
x-forwarded-for:"54.240.197.14" 
x-forwarded-proto:"https" 

にアマゾンヘッダーのみを参照してください?

答えて

0

デフォルトのexpressボディーセーバーがリクエストの本文をクリーンアップしていることがわかりました。 この回答からコードを実装しました。私の体にデータがあります!

https://stackoverflow.com/a/22871339/4548006

関連する問題