Solved

System Management Server(SMS) & ASP

Posted on 2000-05-10
12
444 Views
Last Modified: 2008-10-12
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
Comment
Question by:weesiong
  • 6
  • 2
  • 2
  • +2
12 Comments
 

Accepted Solution

by:
Tension earned 120 total points
Comment Utility

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
 

Expert Comment

by:Tension
Comment Utility

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
 
LVL 7

Author Comment

by:weesiong
Comment Utility
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
 
LVL 7

Author Comment

by:weesiong
Comment Utility
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
 
LVL 3

Expert Comment

by:Hencah
Comment Utility
hmm this is very interesting. I wonder I could know how to implement that using asp like www.mtnsms.com did.
0
 
LVL 7

Author Comment

by:weesiong
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 7

Author Comment

by:weesiong
Comment Utility
Adjusted points from 100 to 120
0
 

Expert Comment

by:kannarama
Comment Utility
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
 

Expert Comment

by:kannarama
Comment Utility
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
 
LVL 7

Author Comment

by:weesiong
Comment Utility
although no is a asp i want, but i have learn more about sms. Thanx!
0
 

Expert Comment

by:ctlim
Comment Utility
hello weesiong, please give me a contact email to me, mine is damonlim@viztel.com
I would like to talk to you further.
0
 
LVL 7

Author Comment

by:weesiong
Comment Utility
sure you can, my email@address is weesiong@rocketmai.com ; i also come from Malaysia~@@~
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now