• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 459
  • Last Modified:

System Management Server(SMS) & ASP

How to use asp to control a SMS and send a SMS message to mobile phone use, what program i need, and please give me a simple code to try it, thanx!
0
weesiong
Asked:
weesiong
  • 6
  • 2
  • 2
  • +2
1 Solution
 
TensionCommented:

Hi weesiong

   actually the prgm. is written VB...
 
first u have to register in sms-wap.com to u r userid.  

    use these controls in u r form ...

winsock, and two text boxes, one for sending the message and the other for typing the mobile no. and two command button BtnSend and BtnExit..

Here winsock is named as Inet, the text entered for message name as Message and the textbox entered for the Mobile no is named as Numlist.

'****************************************' This example demonstrates how to submit a SMS message to the
' NovelSoft SMSC from a Visual Basic program

************************************************************

' PUT YOUR OWN SMS USERNAME AND PASSWORD HERE
Const USERNAME = "test1234"
Const PASSWORD = "test3456"
Const TEST = 1  ' For debugging purposes only

Dim buffer As String


' Terminate the application
'
Private Sub BtnExit_Click()
    ' Terminate the application
    End
End Sub


' Send a message!
'
Private Sub BtnSend_Click()
    Dim query As String, headers As String
    Dim qlen As Integer
    Dim msg As String, c As String
    Dim res As Integer
    Dim i As Integer
   
    ' Convert special characters in the message text
    msg = ""
    For i = 1 To Len(Message.Text)
        c = Mid(Message.Text, i, 1)
        Select Case c
            Case "&": c = "%26"
            Case "+": c = "%2B"
            Case "%": c = "%25"
            Case "#": c = "%23"
            Case "=": c = "%3D"
            Case " ": c = "%20"
        End Select
        msg = msg + c
    Next
   
    ' Construct the HTTP query string
    query = "UID=" & USERNAME _
            & "&PW=" & PASSWORD _
            & "&TEST=" & TEST _
            & "&NUMLIST=" & Numlist.Text _
            & "&MSG=" & msg
    qlen = Len(query)
   
    res = MsgBox(query & vbCrLf & "(Length: " & qlen & ")", vbOKCancel, "Query String:")
    If res = vbOK Then
   
        ' Connect to the server
        buffer = ""
        Inet.RemoteHost = "www.sms-wap.com": Inet.RemotePort = 80: Inet.Connect
        While (Inet.State <> sckConnected) And (Inet.State <> sckError): DoEvents: Wend
       
        If Inet.State = sckConnected Then
            ' Transmit the request to the server via Execute()
            headers = "Host: www.sms-wap.com" & vbCrLf _
                        & "Content-length: " & qlen & vbCrLf _
                        & "Content-type: application/x-www-form-urlencoded"
   
            Inet.SendData "POST /cgi/csend.cgi HTTP/1.0" & vbCrLf _
                            & headers & vbCrLf & vbCrLf _
                            & query
            While (Inet.State = sckConnected): DoEvents: Wend
            Inet.Close
           
            ' Get response code and strip HTTP header
            i = InStr(1, buffer, vbCrLf & vbCrLf)
            If i > 0 Then buffer = Mid(buffer, i + 4)
            MsgBox "The server response was: " & buffer
        Else
            MsgBox "Could not connect to server"
        End If
    End If
End Sub


' This routine is called by the Internet Control during transfer. We use it
' to gather the response code.
'
Private Sub Inet_DataArrival(ByVal n As Long)
    Dim s As String
   
    s = ""
    Inet.GetData s, vbString
    buffer = buffer + s
End Sub
0
 
TensionCommented:

Hi weesiong

   actually the prgm. is written VB...
 
first u have to register in sms-wap.com to u r userid.  

    use these controls in u r form ...

winsock, and two text boxes, one for sending the message and the other for typing the mobile no. and two command button BtnSend and BtnExit..

Here winsock is named as Inet, the text entered for message name as Message and the textbox entered for the Mobile no is named as Numlist.

'****************************************' This example demonstrates how to submit a SMS message to the
' NovelSoft SMSC from a Visual Basic program

************************************************************

' PUT YOUR OWN SMS USERNAME AND PASSWORD HERE
Const USERNAME = "test1234"
Const PASSWORD = "test3456"
Const TEST = 1  ' For debugging purposes only

Dim buffer As String


' Terminate the application
'
Private Sub BtnExit_Click()
    ' Terminate the application
    End
End Sub


' Send a message!
'
Private Sub BtnSend_Click()
    Dim query As String, headers As String
    Dim qlen As Integer
    Dim msg As String, c As String
    Dim res As Integer
    Dim i As Integer
   
    ' Convert special characters in the message text
    msg = ""
    For i = 1 To Len(Message.Text)
        c = Mid(Message.Text, i, 1)
        Select Case c
            Case "&": c = "%26"
            Case "+": c = "%2B"
            Case "%": c = "%25"
            Case "#": c = "%23"
            Case "=": c = "%3D"
            Case " ": c = "%20"
        End Select
        msg = msg + c
    Next
   
    ' Construct the HTTP query string
    query = "UID=" & USERNAME _
            & "&PW=" & PASSWORD _
            & "&TEST=" & TEST _
            & "&NUMLIST=" & Numlist.Text _
            & "&MSG=" & msg
    qlen = Len(query)
   
    res = MsgBox(query & vbCrLf & "(Length: " & qlen & ")", vbOKCancel, "Query String:")
    If res = vbOK Then
   
        ' Connect to the server
        buffer = ""
        Inet.RemoteHost = "www.sms-wap.com": Inet.RemotePort = 80: Inet.Connect
        While (Inet.State <> sckConnected) And (Inet.State <> sckError): DoEvents: Wend
       
        If Inet.State = sckConnected Then
            ' Transmit the request to the server via Execute()
            headers = "Host: www.sms-wap.com" & vbCrLf _
                        & "Content-length: " & qlen & vbCrLf _
                        & "Content-type: application/x-www-form-urlencoded"
   
            Inet.SendData "POST /cgi/csend.cgi HTTP/1.0" & vbCrLf _
                            & headers & vbCrLf & vbCrLf _
                            & query
            While (Inet.State = sckConnected): DoEvents: Wend
            Inet.Close
           
            ' Get response code and strip HTTP header
            i = InStr(1, buffer, vbCrLf & vbCrLf)
            If i > 0 Then buffer = Mid(buffer, i + 4)
            MsgBox "The server response was: " & buffer
        Else
            MsgBox "Could not connect to server"
        End If
    End If
End Sub


' This routine is called by the Internet Control during transfer. We use it
' to gather the response code.
'
Private Sub Inet_DataArrival(ByVal n As Long)
    Dim s As String
   
    s = ""
    Inet.GetData s, vbString
    buffer = buffer + s
End Sub
0
 
weesiongAuthor Commented:
Thank you for your comment, but i still got some problem

1) I canot register a new account in the www.sms-wap.com, because my mobile phone canot received the login name and password from the server after i register it

2) In my country also have a website as like www.sms-wap.com let the use send a sms message to mobile phone(for my country malaysia only). In also same, register 1st, and after it, u can goto send a sms message but just 15msg per-day. But now i hope i can use what the vb program u give me to send a message to other mobile phone use, but it no succefully, and this is my code;

Const USERNAME = "9732031"
Const PASSWORD = "weesiong"
Const TEST = 1  ' For debugging purposes only

Dim buffer As String


' Terminate the application
'
Private Sub BtnExit_Click()
    ' Terminate the application
    End
End Sub


' Send a message!
'
Private Sub BtnSend_Click()
    Dim query As String, headers As String
    Dim qlen As Integer
    Dim msg As String, c As String
    Dim res As Integer
    Dim i As Integer
     
    ' Convert special characters in the message text
    msg = ""
    For i = 1 To Len(message.Text)
        c = Mid(message.Text, i, 1)
        Select Case c
            Case "&": c = "%26"
            Case "+": c = "%2B"
            Case "%": c = "%25"
            Case "#": c = "%23"
            Case "=": c = "%3D"
            Case " ": c = "%20"
        End Select
        msg = msg + c
    Next
     
    ' Construct the HTTP query string
    'query = "UID=" & USERNAME _
    '        & "&PW=" & PASSWORD _
    '        & "&TEST=" & TEST _
    '        & "&NUMLIST=" & numlist.Text _
    '        & "&MSG=" & msg
    query = "session_key=798678929" _
            & "&function=confirmSend" _
            & "&telephone=" & numlist.Text _
            & "&username=9732031" _
            & "&message=" & msg _
            & "&phonebookname="
           
    qlen = Len(query)
     
    res = MsgBox(query & vbCrLf & "(Length: " & qlen & ")", vbOKCancel, "Query String:")
    If res = vbOK Then
     
        ' Connect to the server
        buffer = ""
        Inet.RemoteHost = "sms.catcha.com.my": Inet.RemotePort = 80: Inet.Connect
        While (Inet.State <> sckConnected) And (Inet.State <> sckError): DoEvents: Wend
         
        If Inet.State = sckConnected Then
            ' Transmit the request to the server via Execute()
            headers = "Host: sms.catcha.com.my" & vbCrLf _
                        & "Content-length: " & qlen & vbCrLf _
                        & "Content-type: application/x-www-form-urlencoded"
     
            Inet.SendData "POST cgi-bin/4-4.cgi HTTP/1.0" & vbCrLf _
                            & headers & vbCrLf & vbCrLf _
                            & query
            While (Inet.State = sckConnected): DoEvents: Wend
            Inet.Close
             
            ' Get response code and strip HTTP header
            i = InStr(1, buffer, vbCrLf & vbCrLf)
            If i > 0 Then buffer = Mid(buffer, i + 4)
            MsgBox "The server response was: " & buffer
        Else
            MsgBox "Could not connect to server"
        End If
    End If
End Sub


' This routine is called by the Internet Control during transfer. We use it
' to gather the response code.
'
Private Sub Inet_DataArrival(ByVal n As Long)
    Dim s As String
     
    s = ""
    Inet.GetData s, vbString
    buffer = buffer + s
End Sub

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
weesiongAuthor Commented:
Thank you for your comment, but i still got some problem

1) I canot register a new account in the www.sms-wap.com, because my mobile phone canot received the login name and password from the server after i register it

2) In my country also have a website as like www.sms-wap.com let the use send a sms message to mobile phone(for my country malaysia only). In also same, register 1st, and after it, u can goto send a sms message but just 15msg per-day. But now i hope i can use what the vb program u give me to send a message to other mobile phone use, but it no succefully, and this is my code;

Const USERNAME = "9732031"
Const PASSWORD = "weesiong"
Const TEST = 1  ' For debugging purposes only

Dim buffer As String


' Terminate the application
'
Private Sub BtnExit_Click()
    ' Terminate the application
    End
End Sub


' Send a message!
'
Private Sub BtnSend_Click()
    Dim query As String, headers As String
    Dim qlen As Integer
    Dim msg As String, c As String
    Dim res As Integer
    Dim i As Integer
     
    ' Convert special characters in the message text
    msg = ""
    For i = 1 To Len(message.Text)
        c = Mid(message.Text, i, 1)
        Select Case c
            Case "&": c = "%26"
            Case "+": c = "%2B"
            Case "%": c = "%25"
            Case "#": c = "%23"
            Case "=": c = "%3D"
            Case " ": c = "%20"
        End Select
        msg = msg + c
    Next
     
    ' Construct the HTTP query string
    'query = "UID=" & USERNAME _
    '        & "&PW=" & PASSWORD _
    '        & "&TEST=" & TEST _
    '        & "&NUMLIST=" & numlist.Text _
    '        & "&MSG=" & msg
    query = "session_key=798678929" _
            & "&function=confirmSend" _
            & "&telephone=" & numlist.Text _
            & "&username=9732031" _
            & "&message=" & msg _
            & "&phonebookname="
           
    qlen = Len(query)
     
    res = MsgBox(query & vbCrLf & "(Length: " & qlen & ")", vbOKCancel, "Query String:")
    If res = vbOK Then
     
        ' Connect to the server
        buffer = ""
        Inet.RemoteHost = "sms.catcha.com.my": Inet.RemotePort = 80: Inet.Connect
        While (Inet.State <> sckConnected) And (Inet.State <> sckError): DoEvents: Wend
         
        If Inet.State = sckConnected Then
            ' Transmit the request to the server via Execute()
            headers = "Host: sms.catcha.com.my" & vbCrLf _
                        & "Content-length: " & qlen & vbCrLf _
                        & "Content-type: application/x-www-form-urlencoded"
     
            Inet.SendData "POST cgi-bin/4-4.cgi HTTP/1.0" & vbCrLf _
                            & headers & vbCrLf & vbCrLf _
                            & query
            While (Inet.State = sckConnected): DoEvents: Wend
            Inet.Close
             
            ' Get response code and strip HTTP header
            i = InStr(1, buffer, vbCrLf & vbCrLf)
            If i > 0 Then buffer = Mid(buffer, i + 4)
            MsgBox "The server response was: " & buffer
        Else
            MsgBox "Could not connect to server"
        End If
    End If
End Sub


' This routine is called by the Internet Control during transfer. We use it
' to gather the response code.
'
Private Sub Inet_DataArrival(ByVal n As Long)
    Dim s As String
     
    s = ""
    Inet.GetData s, vbString
    buffer = buffer + s
End Sub

Can you tell me why i have got his error ;
The server response was: <!DOCTYPE HTML PUBLIC" -//IETF//DTD HTML 2.0??EN">
<HTNL><HEAD>
<TITLE>400 Bad Request</TITLE>
</HEAD><BODY>
<H1>Bad Request</H1>
Your browser sent a request that this server could not understabd.<P>
Invalie URl in request POST cgi-bin/4-4.cgi HTTP/1.0<P>
<HR>
<ADDRESS>Apache/1.3.11 Server at melissa,catcha.com Port 80</ADDRESS>
</BODY></HTML>

0
 
HencahCommented:
hmm this is very interesting. I wonder I could know how to implement that using asp like www.mtnsms.com did.
0
 
weesiongAuthor Commented:
i hope i can write a sms(short message service) with asp, are you have any comment? If i dont want use www.sms-wap.com server, what software i need? and i hope i can use modem to send the sms. what i need to setting and how to write a simple asp script? Thanx!
0
 
weesiongAuthor Commented:
Adjusted points from 100 to 120
0
 
kannaramaCommented:
hi weesiong.

yes ofcourse you can do write program which acts like a server(for eg: www.sms-wap.com), what you need is a SMS gateway for that.

you can download the gateway from www.winsms.com for free.

once you have downloaded it, Contact your local mobile phone service providers and get their unique id from them, which is more or like an IP address. once you have try sending messege through your ASP page or with the VB program provided in the sms-wap.com.

But www.sms-wap.com charges for each messege you send. So setting up your own gateway and sending messeges would be a better idea.

Once you are all set. please do inform me.


regards

kannan


0
 
kannaramaCommented:
Rather than routing from sms-wap.com you can have your own gateway registered and route the messege transfer. So you dont have to pay heavily as for using sms-wap.com
0
 
weesiongAuthor Commented:
although no is a asp i want, but i have learn more about sms. Thanx!
0
 
ctlimCommented:
hello weesiong, please give me a contact email to me, mine is damonlim@viztel.com
I would like to talk to you further.
0
 
weesiongAuthor Commented:
sure you can, my email@address is weesiong@rocketmai.com ; i also come from Malaysia~@@~
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now