Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用TwilioAPI发送海量文本_Node.js_Api_Text_Twilio_Mass - Fatal编程技术网

Node.js 使用TwilioAPI发送海量文本

Node.js 使用TwilioAPI发送海量文本,node.js,api,text,twilio,mass,Node.js,Api,Text,Twilio,Mass,我正试图通过以下视频建立一个大众文本: 尝试运行时,我收到以下错误: SyntaxError: Unexpected token : at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:

我正试图通过以下视频建立一个大众文本:

尝试运行时,我收到以下错误:

SyntaxError: Unexpected token :
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/Users/wesleymoore/Downloads/Twilio Passthrough 
Friday/node_modules/node-env-run/dist/bin/node-env-run.js:21:5)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! passthrough@1.0.0 start: `nodenv .`
npm ERR! Exit status 1

要发送批量消息,您需要一个收件人数组,然后在该数组上循环,每次使用不同的号码调用您的函数。如twilio文档所示

以下是文档中的一个片段:

var numbersToMessage = ["+15558675310", "+14158141829", "+15017122661"]

numbersToMessage.forEach(function(number){
  var message = client.messages.create({
    body: 'This is the ship that made the Kessel Run in fourteen parsecs?',
    from: '+16468635472',
    to: number
  })
  .then(message =>  console.log(message.status))
  .done();
});

您能否共享正在运行的导致该错误的代码?
var numbersToMessage = ["+15558675310", "+14158141829", "+15017122661"]

numbersToMessage.forEach(function(number){
  var message = client.messages.create({
    body: 'This is the ship that made the Kessel Run in fourteen parsecs?',
    from: '+16468635472',
    to: number
  })
  .then(message =>  console.log(message.status))
  .done();
});