Sinatra AWS SNS 端点 - 需要帮助

发布于 2024-10-06 07:24:11 字数 1018 浏览 5 评论 0原文

你好,
由于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哎呦我呸! 2024-10-13 07:24:11

一年零四个月后,反思这个问题:

那是因为我是一个彻头彻尾的菜鸟,当时我不知道 Ruby 中的 Hash 是什么

在你的 post 块中,像这样访问哈希的内容:

post "/" do
  puts params['Message']
  halt 200
end 

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:

post "/" do
  puts params['Message']
  halt 200
end 

The message SNS sends you will be printed out to STDOUT/your terminal

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文