Question

I'm sending an SMS from my web application which is build in ASP.NET C# but for some reason when I add the SourceAddress with parameter.Add("SourceAddress", "BPD.co.uk"); the working BPD.co.uk comes through as BPDcouk.

How can I make the points appear?

Heres my C# code:

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);
}

Heres the call to the 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;

}
Was it helpful?

Solution

I guessing that the API you are using is sanitising your parameters and removing stuff it thinks shouldn't be there. You could try escaping the values for your parameters and adding slashes like BPD\.co\.uk and see what happens

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top