1

我正在从构建在 ASP.NET C# 中的 Web 应用程序发送短信,但由于某种原因,当我添加工作时SourceAddress,它会通过.parameter.Add("SourceAddress", "BPD.co.uk");BPD.co.ukBPDcouk

我怎样才能使积分出现?

这是我的 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;

}
4

1 回答 1

0

我猜你正在使用的 API 正在清理你的参数并删除它认为不应该存在的东西。您可以尝试转义参数的值并添加像 BPD\.co\.uk 这样的斜线,看看会发生什么

于 2012-04-17T10:47:00.287 回答