[英]sending sms using textbelt api not working
I have a scenario where i need to send sms through my application for that i am using textbelt api service but its giving me error saying cannot read the property 'length of undefined' 我有一种情况,我需要通过我的应用程序发送短信,因为我正在使用textbelt api服务,但是它给我错误,提示我无法读取属性“未定义的长度”
I m using express.js framework 我正在使用express.js框架
Controller code: 控制器代码:
var text = require('textbelt');
exports.sendSms = function(req, res) {
var opts = {
fromAddr: 'sthakur@innominds.com', // "from" address in received text
fromName: 'shikha', // "from" name in received text
region: 'india', // region the receiving number is in: 'us', 'canada', 'intl'
subject: 'something' // subject of the message
}
text.sendText('9032400119', 'A sample text message!',opts);
};
and routing part: 和路由部分:
'use strict';
var express = require('express');
var controller = require('./sms.controller');
router.get('/', controller.index);
router.get('/sendSms', controller.sendSms);
router.get('/:id', controller.show);
router.post('/', controller.create);
router.put('/:id', controller.update);
router.patch('/:id', controller.update);
router.delete('/:id', controller.destroy);
module.exports = router;
I dont have any idea why that error is coming 我不知道为什么会出现这个错误
any help is highly appreciated 任何帮助都受到高度赞赏
UPDATE: 更新:
I tried by giving region as us and i get the log 我尝试通过给我们提供区域来获取日志
This is what i tried, for which i get 'SMS SENT' log in my console, but SMS is not being sent . 这是我尝试过的操作,为此我在控制台中获取了“ SMS SENT”日志,但未发送SMS。
var opts = {
fromAddr: '%s@email.uscc.net', // "from" address in received text
fromName: 'User', // "from" name in received text
region: 'us', // region the receiving number is in: 'us', 'canada', 'intl'
subject: 'Test SMS' // subject of the message
}
text.sendText('82*****', 'A sample text message!', opts);
console.log(opts)
console.log('SMS SENT')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.