Example api code for Promotional SMS in asp.net

Replace user, password, msisdn, sid and message accordingly.

 

1. Below is the sample code for asp.net for Single Message:

using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
static async Task Main()
{
string apiUrl = "http://sms.domainadda.com/vendorsms/pushsms.aspx";
string user = "abc";
string password = "xyz";
string msisdn = "919898xxxxxx";
string sid = "SenderId";
string message = "test message";
string fl = "0";

var parameters = new System.Collections.Generic.Dictionary<string, string>
{
{ "user", user },
{ "password", password },
{ "msisdn", msisdn },
{ "sid", sid },
{ "msg", message },
{ "fl", fl }
};

var httpClient = new HttpClient();
var response = await httpClient.GetAsync(apiUrl + "?" + await new FormUrlEncodedContent(parameters).ReadAsStringAsync());

if (response.IsSuccessStatusCode)
{
string apiResponse = await response.Content.ReadAsStringAsync();
Console.WriteLine("API response: " + apiResponse);
}
else
{
Console.WriteLine("Error: " + response.ReasonPhrase);
}
}
}

 

2. Below is the sample code for asp.net for Multiple Messages:

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
static async Task Main()
{
string apiUrl = "http://sms.domainadda.com/vendorsms/pushsms.aspx";
string user = "abc";
string password = "xyz";
string msisdns = "919898xxxxxx,919898xxxxxx"; // Comma-separated list of phone numbers
string sid = "SenderId";
string message = "test message";
string fl = "0";

var parameters = new Dictionary<string, string>
{
{ "user", user },
{ "password", password },
{ "msisdn", msisdns },
{ "sid", sid },
{ "msg", message },
{ "fl", fl }
};

using (var httpClient = new HttpClient())
{
var response = await httpClient.PostAsync(apiUrl, new FormUrlEncodedContent(parameters));

if (response.IsSuccessStatusCode)
{
string apiResponse = await response.Content.ReadAsStringAsync();
Console.WriteLine("API response: " + apiResponse);
}
else
{
Console.WriteLine("Error: " + response.ReasonPhrase);
}
}
}
}

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Example api code for Promotional SMS in php

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in java

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in ruby

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in node,js

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in python

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...