我正在使用 Plivo 向用户发送短信以进行 otp 验证,我无法为不同用户更新手机号码和消息参数,这是我的代码
global.params = {
'src': 'xx-xxxx', // Sender's phone number with country code
'dst' : '91'+'xxxxxxxxxx', // Receiver's phone Number with country code
'text' : "Hi, message from Plivo", // Your SMS Text Message - English
'url' : "https://intense-brook-8241.herokuapp.com/report/", // The URL to which with the status of the message is sent
'method' : "GET" // The method used to call the url
};
module.exports={
foo: function createOTPverify(mobile_number, id){
var motp = randomize('0',4);
console.log("motp "+motp);
global.params.dst = mobile_number;
global.params.text = "Hi, your verification one time password is "+motp;
p.send_message(global.params, function(status, response){
console.log('Status: ', status);
console.log('API Response:\n', response);
})
}
}
这里一切正常但无法更新参数,我尝试使用全局但仍然无法做到,请帮助