Sinatra AWS SNS 端点 - 需要帮助
你好,
由于 Amazon SNS 终端节点的未记录性质以及它们与用户交互的方式,我正在努力在 Sinatra 中为我的应用程序编写终端节点。 我有一些用 PHP 此处编写的代码,但我正在努力转换将其放入 Ruby 数组中,因为 request.env["rack.input"].read
将所有内容封装到类似于 PHP 数组的内容中:
{"Message"=>"chapstick", "Subject"=>"cherry", "Signature"=>"QutYUXuqWQqiAY4PUvd+Hq+9KWSvPVwck22oV0pXkgSg0p+kZ/2Q+pS24siDPKxxHB8+ru5q6 QBqQv+RHKWobiLiupEf4UP1MQu3lnP4Z2TYWvbHVjNiO5OutcaivPrn08EIBTOMsWl2i8JmaTBXozOp4r1vheqg6k/wWDoUmd0=", "TopicArn"=>"arn:aws:sns:us-east-1:687180262489:plinklebird", "SignatureVersion"=>"1", "Timestamp"=>"2010-12-03T22:10:01.141Z", "MessageId"=>"dc8a8502-44a8-41ec-9616-1d049f00724d", "UnsubscribeURL"=>"https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:687180262489:plinklebird:99e83fd5-58a9-41bb-82bd-9920a1ee1a94", "Type"=>"Notification"}
我不知道如何处理这个问题,有人可以帮忙吗?
非常感谢您的宝贵时间,
卢克·卡彭特
Hiya,
Due to the undocumented nature of the Amazon SNS endpoints and how they interact with the user, I am struggling to code an endpoint in Sinatra for my application.
I have some code written in PHP here, but I am struggling to convert it into a Ruby array because request.env["rack.input"].read
encapsulates everything into something similar to a PHP array:
{"Message"=>"chapstick", "Subject"=>"cherry", "Signature"=>"QutYUXuqWQqiAY4PUvd+Hq+9KWSvPVwck22oV0pXkgSg0p+kZ/2Q+pS24siDPKxxHB8+ru5q6 QBqQv+RHKWobiLiupEf4UP1MQu3lnP4Z2TYWvbHVjNiO5OutcaivPrn08EIBTOMsWl2i8JmaTBXozOp4r1vheqg6k/wWDoUmd0=", "TopicArn"=>"arn:aws:sns:us-east-1:687180262489:plinklebird", "SignatureVersion"=>"1", "Timestamp"=>"2010-12-03T22:10:01.141Z", "MessageId"=>"dc8a8502-44a8-41ec-9616-1d049f00724d", "UnsubscribeURL"=>"https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:687180262489:plinklebird:99e83fd5-58a9-41bb-82bd-9920a1ee1a94", "Type"=>"Notification"}
I am not sure how to handle this, can anybody please help?
Thank you very much for your time,
Luke Carpenter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一年零四个月后,反思这个问题:
那是因为我是一个彻头彻尾的菜鸟,当时我不知道 Ruby 中的 Hash 是什么
在你的
post
块中,像这样访问哈希的内容:SNS 发送给您的消息将被打印到 STDOUT/您的终端
A year and four months later, reflecting on this problem:
It was because I was a complete and utter noob, and I didn't know what a Hash was in Ruby at the time
In your
post
block, access the contents of the hash like so:The message SNS sends you will be printed out to STDOUT/your terminal