【发布时间】:2017-12-17 15:56:40
【问题描述】:
我正在从构建在 ASP.NET C# 中的 Web 应用程序发送短信,但由于某种原因,当我添加 SourceAddress 和 parameter.Add("SourceAddress", "BPD.co.uk"); 时,工作中的 BPD.co.uk 以 BPDcouk 的形式出现。
我怎样才能让点出现?
这是我的 C# 代码:
public void SendSms(string MobileNumber, string SMSContent)
{
Dictionary<string, string> parameter = new Dictionary<string, string>();
parameter.Add("Action", "Send");
parameter.Add("DestinationAddress", MobileNumber);
parameter.Add("SourceAddress", "BPD.co.uk");
parameter.Add("Body", SMSContent);
parameter.Add("ValidityPeriod", "86400");
string resultcode = api_connect("nsp04456", "pword", parameter);
}
这是对 API_Connect 的调用
private string api_connect(string Username, string Password, Dictionary<string, string> ParametersDict)
{
string url = "http://api.sms.co.uk/api/api.php";
string poststring = "Username=" + Username + "&";
poststring = poststring + "Password=" + Password;
// Turn the parameter dictionary object into the variables
foreach (KeyValuePair<string, string> item in ParametersDict)
{
poststring = poststring + "&" + item.Key + "=" + item.Value;
}
MSXML2.ServerXMLHTTP60 xmlHttp = new MSXML2.ServerXMLHTTP60();// Server.CreateObject("MSXML2.ServerXMLHTTP.4.0");
xmlHttp.open("POST", url, false);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send(poststring);
return xmlHttp.responseText;
}
【问题讨论】:
-
这会将“BPD.co.uk”添加到字典中......之后会发生什么完全取决于“api_connect”的功能以及您调用的特定 API
标签: c# asp.net xmlhttprequest serverxmlhttp