【问题标题】:Is there a way to build a complete sendgrid subscribtion form using only sendgrid's API?有没有办法只使用 sendgrid API 来构建完整的 sendgrid 订阅表单?
【发布时间】:2021-12-13 23:56:00
【问题描述】:

我正在尝试使用他们的 API 构建自己的 sendgrid 订阅表单。 不幸的是,https://www.npmjs.com/package/@sendgrid/subscription-widget 是我能找到的唯一解决方案,它需要一个我不需要的 Heroku 帐户。 我只是想了解在不使用第三方应用的情况下订阅邮件列表的 API 请求应该是什么样的。

【问题讨论】:

标签: email sendgrid subscription newsletter


【解决方案1】:

这里是 Twilio SendGrid 开发人员宣传员。

是的,您可以创建自己的订阅表格。要在列表中创建新联系人,您可以使用the create contacts API

在 JavaScript 中,使用 API 如下所示:

const { Client } = require("@sendgrid/client");
const client = new Client();
client.setApiKey(process.env.SENDGRID_API_KEY);

const request = {
  method: "PUT",
  url: "/v3/marketing/contacts",
  body: {
    contacts: [{ email: "test@example.com", first_name: "Test" }],
  },
};
client.request(request)
  .then(console.log)
  .catch(console.error);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    • 1970-01-01
    • 1970-01-01
    • 2014-11-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多