我正在尝试使用mysms API发送短信。我可以使用以下示例发送到单个号码:
示例:https://api.mysms.com/json/message/send?api_key=xxxxx&msisdn=xxx&password=xxx&recipient=436761234567&message=Hi
如何使用以上示例发送多个号码?
答案 0 :(得分:1)
我想到了以下代码:
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);
}
}
现在只需拨打电话:
sendSMS();
此代码是javascript,希望您能很好地回答您的问题。此外,它已经过测试并证明是有效的。总是有改进的空间。