【发布时间】:2017-08-16 13:50:21
【问题描述】:
我在 Node.js
中发送短信的代码var accountSid = ''; // Your Account SID from www.twilio.com/console
var authToken = ''; // Your Auth Token from www.twilio.com/console
// Load the twilio module
var twilio = require('twilio');
// Create a new REST API client to make authenticated requests against the
// twilio back end
var client = new twilio(accountSid, authToken);
// Pass in parameters to the REST API using an object literal notation. The
// REST client will handle authentication and response serialzation for you.
client.messages.create({
to: 'my_number', // verified
from: '+15005550006', // From a valid Twilio number
body:'ahoy hoy! Testing Twilio and node.js'
}, function(error, message) {
// The HTTP request to Twilio will run asynchronously. This callback
// function will be called when a response is received from Twilio
// The "error" variable will contain error information, if any.
// If the request was successful, this value will be "falsy"
if (!error) {
// The second argument to the callback will contain the information
// sent back by Twilio for the request. In this case, it is the
// information about the text messsage you just sent:
console.log('Success! The SID for this SMS message is:');
console.log(message.sid);
console.log('Message sent on:');
console.log(message.dateCreated);
} else {
console.log('Oops! There was an error.');
console.log(error)
}
});
一切正常,但我没有收到 Actual/Real SMS 那么我如何通过仅在控制台上看到成功结果来确认。这就是为什么我想获得 Actual/真正的短信不仅仅是控制台中的成功消息?
因此没有规定使用试用帐户获取实际消息。
任何建议、建议或答案都会对我更有帮助 提前致谢!
【问题讨论】:
-
您使用的是实时凭据还是测试凭据?
标签: node.js sms twilio sms-gateway twilio-api