C#
//Your UserId, Password and VASId
string userid = "Your USERID";
string password = "Your Password";
string vasid = "Your VASID";
//Multiple mobiles numbers separated by comma
string to= "16091239999"; //In international format, must be prefixed with a valid country code
//Text number; send from number either a short code or a local number.
string from = "27126";
//Your Text message must be URL encoded
string text = HttpUtility.UrlEncode("Sample Text message");
//post parameters
StringBuilder sPost = new StringBuilder();
sPost.AppendFormat("userid={0}", userid);
sPost.AppendFormat("password={0}", password);
sPost.AppendFormat("vasid={0}", vasid);
sPost.AppendFormat("&to={0}", to);
sPost.AppendFormat("&text={0}", text);
sPost.AppendFormat("&from={0}", from);
try
{
//Call SMS API
string SMSCURL = "https://msgapi.wire2air.com/smsapi/submitsm.aspx";
HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(SMSCURL);
UTF8Encoding encoding = new UTF8Encoding();
byte[] data = encoding.GetBytes(sPost.ToString());
httpReq.Method = "POST";
httpReq.ContentType = "application/x-www-form-urlencoded";
httpReq.ContentLength = data.Length;
using (Stream stream = httpReq.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
HttpWebResponse response = (HttpWebResponse)httpReq.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string responseString = reader.ReadToEnd();
//Close the response
reader.Close();
response.Close();
}
catch (SystemException ex)
{
MessageBox.Show(ex.Message.ToString());
}
ASP
sstrData = “To=” & [Mobile Number]
sstrData = sstrData + “&From=27126”
sstrData = sstrData + “&UserId=” + Server.URLEncode(“xxxxx”)
SstrData = sstrData + “&Password=” + Server.URLEncode(“xxxxx”)
SstrData = sstrData + “&vasid=XXXX”
SstrData = sstrData + “&Text=” + Server.URLEncode(“Demo Message”)
Set myhttp=CreateObject (“Msxml2.XMLHTTP”)
Myhttp.open (“POST”, “https://msgapi.wire2air.com/smsapi/submitsm.aspx”, false)
Myhttp.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded”
Myhttp.send sstrData
Response.write myhttp.responsetext
Set myhttp = Nothing
Python
import urllib # Python URL functions
import urllib2 # Python URL functions
userid= YOUR_USERID
password=YOUR_PASSWORD
vasid=YOUR_VASID
to = "16092223333" # Multiple mobiles numbers separated by comma.
text = "Test message" # Your message to send.
from = "27126" # Specify your shortcode or virtual number
# Prepare the post parameters
values = {
'userid' : userid,
'password' : password,
'vasid' :vasid,
'to' : to,
'text' : text,
'from' : from
}
url = "https://msgapi.wire2air.com/smsapi/submitsm.aspx" # API URL
postdata = urllib.urlencode(values) # URL encoding the data here.
req = urllib2.Request(url, postdata)
response = urllib2.urlopen(req)
output = response.read() # Get Response
print output # Print Response
PHP
<?php
//Your authentication key
$userid= YOUR_USERID;
$password=YOUR_PASSWORD;
$vasid=YOUR_VASID;
$to = "16092223333";
//Sender ID
$from = "27126";
//Text message to send, make sure to URL encode the content.
$message = urlencode("Test message");
//Prepare post parameters
$postData = array('userid' => $userid,
'password' => $password,
'vasid'=$vasid,
'to' => $to,
'text' => $message,
'from' => $from);
//API URL
$url="https://msgapi.wire2air.com/smsapi/submitsm.aspx";
// init the resource
$ch = curl_init();
curl_setopt_array(
$ch,
array( CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS =>
$postData
));
//Ignore SSL certificate verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//get response
$output = curl_exec($ch);
//Print error if any
if(curl_errno($ch))
{ echo 'error:' . curl_error($ch); }
curl_close($ch);
echo $output;
?>