[英]Sending sms to multiple phonenumbers using mysms API
I'm trying to send sms using mysms API.我正在尝试使用 mysms API 发送短信。 I am able to send to single number using following example:我可以使用以下示例发送到单个号码:
Example: https://api.mysms.com/json/message/send?api_key=xxxxx&msisdn=xxx&password=xxx&recipient=436761234567&message=Hi
示例: https://api.mysms.com/json/message/send?api_key=xxxxx&msisdn=xxx&password=xxx&recipient=436761234567&message=Hi
: https://api.mysms.com/json/message/send?api_key=xxxxx&msisdn=xxx&password=xxx&recipient=436761234567&message=Hi
How can I send to multiple number using above example?如何使用上面的示例发送到多个号码?
I came up with this code:我想出了这个代码:
function sendSMS() {
var apikey = "your api_key";
var mno = 40123123456; // msisdn = your number without +sign in from
var pwd = "yourpassword";
// var no = 40123123456; // single number & replace this with a real one
var grp = [40123123456,40123123456,40123123456]; // multiple numbers / let's call it a group & just replace those with your actual testing numbers
var msg = "Hi!%0aThis is a test message!%0aThis is another row.%0a:D"; // Use %0a to insert a new row in your message
for ( var i in grp ) {
var smsurl = "https://api.mysms.com/json/message/send?api_key="+apikey+"&msisdn="+mno+"&password="+pwd+"&recipient="+grp[i]+"&message="+msg+"";
var xhttp = new XMLHttpRequest();
xhttp.open("GET", smsurl, true);
xhttp.send();
console.log(smsurl);
}
}
Now just make the call:现在只需拨打电话:
sendSMS();
This code is javascript and I hope will answer your question well.这段代码是javascript,我希望能很好地回答你的问题。 Also it was tested and proven that is working.它还经过测试并证明是有效的。 There is always room for improvements.总有改进的余地。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.