Developer Page


Developer Page

Request: http://msg.textline.in/sendsms.aspx

C#

Calling HTTP API Using C#.Net

    using System;
    using System.Collections.Concurrent;
    using System.Collections.Generic;
    using System.IO;
    using System.Net;

    public string SendSMS()
    {
        Uri targetUri = new Uri("msg.textline.in/sendsms.aspx?mobile=9777339883&pass=your pass&senderid=alphanumeric_number_senderID&to=recipient_number&msg=your_message");
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(targetUri);
        webRequest.Method = WebRequestMethods.Http.Get;

        try
        {
            string webResponse = string.Empty;
            using (HttpWebResponse getresponse = (HttpWebResponse)webRequest.GetResponse())
            {
                using (StreamReader reader = new StreamReader(getresponse.GetResponseStream()))
                {
                    webResponse = reader.ReadToEnd();
                    reader.Close();
                }
                getresponse.Close();
            }
            return webResponse;
        }
        catch (System.Net.WebException ex)
        {
            return "Request-Timeout";
        }
        catch (Exception ex)
        {
            return "error";
        }
        finally
        {
            webRequest.Abort();
        }
    }

PHP

<?php
class Sender{
//Username that is to be used for submission
var $strUserName;
//password that is to be used along with username
var $strPassword;
//Sender Id to be used for submitting the message
var $strSenderId;
//Message content that is to be transmitted
var $strMessage;
//Mobile No is to be transmitted
var $strMobile;
public function Sender ($username,$password,$senderid,$message,$mobile){
$this->strUserName = $username;
$this->strPassword = $password;
$this->strSenderId= $senderid;
$this->strMessage=$message; //URL Encode The Message
$this->strMobile=$mobile;
}
public function Submit(){
try{
//http Url to send sms.
$url="msg.textline.in/sendsms.aspx";
$fields = array(
'mobile' => $this->strUserName,
'pass' => $this-> strPassword,
'senderid' => $this-> strSenderId,
'to' => $this-> strMobile,
'msg' => urlencode($this->strMessage)
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .=
$key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
}
catch(Exception $e){
echo 'Message:' .$e->getMessage();
}
}
}
//Call The Constructor.
$obj = new Sender("","","Tester"," ,"Test SMS”, "919990001245");
$obj->Submit ();
?>

VB.NET

Imports System.IO
Imports System.Net
Imports System.Data
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim WebRequest As Net.WebRequest 'object for WebRequest
Dim WebResonse As Net.WebResponse 'object for WebResponse
'Username that is to be used for submission
Dim UserName As String = ""
'password that is to be used along with username
Dim Password As String = ""
'Message content that is to be transmitted
Dim Message As String = "Test SMS"
'Url Encode message
Message = HttpUtility.UrlEncode(Message)
'Sender Id to be used for submitting the message
Dim SenderId As String = "Tester"
'Destinations to which message is to be sent For submitting more than one
destinations should be comma separated Like '91999000123,91999000124
Dim Destination As String = ""
'CODE COMPLETE TO DEFINE PARAMETER
Dim WebResponseString As String = ""
Dim URL As String = "msg.textline.in/sendsms.aspx?mobile=" & 9777339883 &
"&pass=" & Password & "&senderid=" &SenderId & "
&to=" & Destination & "&msg=" & Message & ""
WebRequest = Net.HttpWebRequest.Create(URL) 'Hit URL Link
WebRequest.Timeout = 25000
Try
WebResonse = WebRequest.GetResponse 'Get Response
Dim reader As IO.StreamReader = New
IO.StreamReader(WebResonse.GetResponseStream)
'Read Response and store in variable
WebResponseString = reader.ReadToEnd()
WebResonse.Close()
Response.Write(WebResponseString) 'Display Response.
Catch ex As Exception
WebResponseString = "Request Timeout" 'If any exception occur.
Response.Write(WebResponseString)
End Try
End Sub
End Class

JAVA

Imports System.IO
Imports System.Net
Imports System.Data
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim WebRequest As Net.WebRequest 'object for WebRequest
Dim WebResonse As Net.WebResponse 'object for WebResponse
'Username that is to be used for submission
Dim UserName As String = ""
'password that is to be used along with username
Dim Password As String = ""
'Message content that is to be transmitted
Dim Message As String = "Test SMS"
'Url Encode message
Message = HttpUtility.UrlEncode(Message)
'Sender Id to be used for submitting the message
Dim SenderId As String = "Tester"
'Destinations to which message is to be sent For submitting more than one
destinations should be comma separated Like '91999000123,91999000124
Dim Destination As String = ""
'CODE COMPLETE TO DEFINE PARAMETER
Dim WebResponseString As String = ""
Dim URL As String = "msg.textline.in/sendsms.aspx?mobile=" & 9777339883 &
"&pass=" & Password & "&senderid=" &SenderId & "
&to=" & Destination & "&msg=" & Message & ""
WebRequest = Net.HttpWebRequest.Create(URL) 'Hit URL Link
WebRequest.Timeout = 25000
Try
WebResonse = WebRequest.GetResponse 'Get Response
Dim reader As IO.StreamReader = New
IO.StreamReader(WebResonse.GetResponseStream)
'Read Response and store in variable
WebResponseString = reader.ReadToEnd()
WebResonse.Close()
Response.Write(WebResponseString) 'Display Response.
Catch ex As Exception
WebResponseString = "Request Timeout" 'If any exception occur.
Response.Write(WebResponseString)
End Try
End Sub
End Class

VB6

Private Sub Form_Load()
Dim strUrl as string = "msg.textline.in/sendsms.aspx?mobile=9777339883&pass=your password&senderid=your approved senderid&to=to
number&msg=your message"
Dim objHttp as Object, strText as string
Set objHttp = CreateObject("MSXML2.ServerXMLHTTP")
objHttp.Open "GET", strUr, False
objHttp.setRequestHeader "User-Agent", _
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHttp.Send ("")
strText = objHttp.responseText
Set objHttp = Nothing
End Sub