C# Sample Code (GET)
using System;
using System.Collections.Generic;
using System.Net;
using System.Collections.Specialized;
using System.IO;
namespace sendSMS
{
class sendSMS
{
public string sendSMS()
{
String result;
string apiKey = "your apiKey";
string numbers = "923001234567,923211234567,923451234567"; // in a comma seperated list
string message = "This is your message";
string sender = "Jims Autos";
String url = "https://www.hajanaone.com/api/sendsms.php?apikey=" + apiKey + "&phone=" + numbers + "&message=" + message + "&sender=" + sender;
//refer to parameters to complete correct url string
StreamWriter myWriter = null;
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = Encoding.UTF8.GetByteCount(url);
objRequest.ContentType = "application/x-www-form-urlencoded";
try
{
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(url);
}
catch (Exception e)
{
return e.Message;
}
finally
{
myWriter.Close();
}
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;
}
}
}
C# Sample Code (POST)
using System;
using System.Collections.Generic;
using System.Net;
using System.Collections.Specialized;
namespace sendSMS
{
class sendSMS
{
public string sendSMS()
{
String message = HttpUtility.UrlEncode("This is your message");
using (var wb = new WebClient())
{
byte[] response = wb.UploadValues("https://www.hajanaone.com/api/sendsms.php", new NameValueCollection()
{
{"apikey" , "yourapiKey"},
{"phone" , "923331234567,923001234567,923451234567"},
{"message" , message},
{"sender" , "Jims Autos"}
});
string result = System.Text.Encoding.UTF8.GetString(response);
return result;
}
}
}
}
Caution: Some users opt to place their request inside a code loop, while testing we highly recommend setting the test parameter to true, as occasionally an infinite loop can occur and users can consume all their credits very quickly.