HTTP Send SMS API Using Windows Phone 8 – C#

 In sample code

HTTP Send SMS API Using Windows Phone 8 – C#

try
{
    string strResult = "";
    //Prepare you post parameters
    var postValues = new List<KeyValuePair<string, string>>();
    //Your authentication key
    postValues.Add(new KeyValuePair<string, string>("authkey", "YourAuthKey"));
    //Multiple mobiles numbers separated by comma
    postValues.Add(new KeyValuePair<string, string>("mobiles", "9999999"));
    //Sender ID,While using route4 sender id should be 6 characters long.
    postValues.Add(new KeyValuePair<string, string>("sender", "102234"));
    //Your message to send, Add URL encoding here.
    string message = HttpUtility.UrlEncode("Test message");
    postValues.Add(new KeyValuePair<string, string>("message", message));
    //Select route
    postValues.Add(new KeyValuePair<string, string>("route","default"));

    //Prepare API to send SMS
    Uri requesturl = new Uri("http://priority.muzztech.in/api/sendhttp.php");
    //create httpclient request
    var httpClient = new HttpClient();
    var httpContent = new HttpRequestMessage(HttpMethod.Post, requesturl);
    httpContent.Headers.ExpectContinue = false;
    httpContent.Content = new FormUrlEncodedContent(postValues);
    HttpResponseMessage response = await httpClient.SendAsync(httpContent);

    //Get response
    var result = await response.Content.ReadAsStringAsync();
    strResult = result.ToString();
    response.Dispose();
    httpClient.Dispose();
    httpContent.Dispose();
}
catch (Exception ex)
{
	throw ex;
}
Recent Posts

Leave a Comment

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

0