【问题标题】:How do I send multiple payloads at once to SendGrid's API in Ruby?如何在 Ruby 中一次将多个有效负载发送到 SendGrid 的 API?
【发布时间】:2015-06-01 17:41:44
【问题描述】:

根据他们的API docs,与他们的 API 交互的 curl 命令应该如下所示:

curl -X POST https://api.sendgrid.com/apiv2/reseller.manage.json \
-d api_user=reseller@company.com \
-d api_key=XXXXXXXX \
-d user=reseller_customer@company.com \
-d password=customernewpassword \
-d confirm_password=customernewpassword \
-d method=password

如何在 Ruby 中编写它?

【问题讨论】:

    标签: ruby post sendgrid


    【解决方案1】:

    您需要查看 RestClient gem。它使发送这样的请求变得容易。 https://github.com/rest-client/rest-client

    【讨论】:

    • 这是我需要的功能吗? RestClient.post '/data', {:foo => 'bar', :multipart => true} README 不是很清楚。
    【解决方案2】:

    您可以通过使用 ruby​​ 来使用 SendGrid API 来卷曲 url。如果你不局限于使用 curl,你应该看看官方的 ruby​​ gem https://github.com/sendgrid/sendgrid-ruby

    【讨论】:

    • 不幸的是,gem 只使用了他们的 Web API。我需要使用他们的 Reseller API。
    【解决方案3】:

    使用 Sendgrid SMTP API,他们的文档中有代码示例;例如,请参见此处,https://sendgrid.com/docs/Integrate/Code_Examples/ruby.html

    【讨论】:

      猜你喜欢
      • 2016-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-09
      • 1970-01-01
      • 2017-12-17
      • 2023-01-25
      相关资源
      最近更新 更多