如何使用MVC中的site2sms登录将短信发送到移动设备? [英] How to send sms to mobile using site2sms login in MVC?
问题描述
我试过这段代码并得到这样的例外
{message:无效的Mashape Key}
ASPSnippets.SmsAPI.dll中出现System.Exception类型的异常,但未在用户代码中处理
我尝试过的:
public void sent()
{
bool isSent = SendOTPSMS(&&&&&& ****,*****,NHa1bjKulkmshpU91Xel3gj94SDKp18z3qcjsnCuDyxq7OOePV,++++++ @@@@, OTP:324353);
}
public static bool SendOTPSMS(string senderMobileNo,string senderPassword,string MshapeKey,string receiverMobileNo,string message)
{
bool isSent = true;
try
{
WebRequest request = WebRequest.Create( https://site2sms.p.mashape.com/index.php?msg=
+消息+& phone =+ receiv erMobileNo +& pwd =+ senderPassword +& uid =+ senderMobileNo);
request.Headers.Add(X-Mashape-Key,MshapeKey);
WebResponse response = request.GetResponse();
返回isSent;
}
catch(例外情况)
{
返回false;
}
}
I tried this code and getting the exception like this
{"message":"Invalid Mashape Key"}
An exception of type System.Exception occurred in ASPSnippets.SmsAPI.dll but was not handled in user code
What I have tried:
public void sent()
{
bool isSent = SendOTPSMS("&&&&&&****", "*****", "NHa1bjKulkmshpU91Xel3gj94SDKp18z3qcjsnCuDyxq7OOePV", "++++++@@@@", "OTP: 324353");
}
public static bool SendOTPSMS(string senderMobileNo, string senderPassword, string MshapeKey, string receiverMobileNo, string Message)
{
bool isSent = true;
try
{
WebRequest request = WebRequest.Create("https://site2sms.p.mashape.com/index.php?msg="
+ Message + "&phone=" + receiverMobileNo + "&pwd=" + senderPassword + "&uid=" + senderMobileNo);
request.Headers.Add("X-Mashape-Key", MshapeKey);
WebResponse response = request.GetResponse();
return isSent;
}
catch (Exception ex)
{
return false;
}
}
推荐答案
错误是非常明显的,你给它一个无效的密钥。联系软件供应商并找出密钥应该是什么,我们无法告诉您。
The error is pretty self-explanatory, you are giving it an invalid key. Contact the software vendor and find out what the key is supposed to be, we can't tell you that.
这篇关于如何使用MVC中的site2sms登录将短信发送到移动设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!