简体   繁体   English

如何通过 twilio 发送群发短信?

[英]How can i send the bulk sms through twilio?

var notification = NotificationResource.Create( serviceSid, toBinding: new List { "{\"binding_type\":\"sms\",\"address\":\"+1651000000000\"}"} body: "Knok-Knok; This is your first Notify SMS"); var notification = NotificationResource.Create( serviceSid, toBinding: new List { "{\"binding_type\":\"sms\",\"address\":\"+1651000000000\"}"} body: "Knok-Knok;这是您的第一条通知短信");

my question is that how i will send the data in toBinding parameter.我的问题是我将如何在 toBinding 参数中发送数据。

Help me帮我

I use JS/Node (so sadly I don't have a C# example).我使用 JS/Node(很遗憾我没有 C# 示例)。 I had success using the technique below.我使用以下技术取得了成功。 Maybe you can reverse engineer to your needs.也许您可以根据您的需求进行逆向工程。

const fetch = require('node-fetch');

const params = new URLSearchParams();
params.append('Body', 'Hello from Node-Fetch!!!');
params.append('ToBinding', '{ "binding_type": "sms", "address": "+14075551212" }');
params.append('ToBinding', '{ "binding_type": "sms", "address": "+18025551212" }');

let headers = {Authorization: 'Basic ' + new Buffer.from(process.env.TWILIO_ACCOUNT_SID + ":" + process.env.TWILIO_AUTH_TOKEN).toString("base64")};

console.log(`To String Output: ${params.toString()}`);

fetch('https://notify.twilio.com/v1/Services/IS076575aa3098c700a174ad0123456789/Notifications',
    {method: 'POST', headers: headers, body: params})
    .then(res => res.json())
    .then(json => console.log(json))
    .catch(err => console.log(err))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM