Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21185

is it a issue with winsock

$
0
0
im making a program which will send sms with the api provided by the company to all the numbers present in my excel file.. im loading the excel file in msflexgrid.. the logic is to send sms to all the numbers present in the msflexgrid..the loading of the excel etc is fine ... below im pasting the code which i m using to send the sms with winsock

Code:


Private Sub cmsSend_Click()
txtResponse.Text = ""
Dim eUrl As URL

Dim strMethod As String
Dim strData As String
Dim strPostData As String
Dim strHeaders As String
Dim strUrl As String
Dim strHTTP As String
Dim X As Integer
Dim i As Integer
Dim user_name As String
Dim pwd As String
Dim sender_name As String
Dim sms_data As String

    user_name = Text2.Text
    pwd = Text3.Text
    sender_name = "infoin"
    sms_data = "username=" & user_name & "&" & "password=" & pwd & "&" & "sendername=" & sender_name & "&"
    strPostData = ""
    strHeaders = ""
    strMethod = "GET"
   
    'This sets the eUrl variable's parameters
    eUrl.Scheme = "http"
    eUrl.Host = "promo.bulksmsnvoice.com"
    eUrl.Port = 80
    eUrl.URI = "/SMSAPI.jsp"
   
    ' configure winsock
    Winsock1.Close
    Winsock1.Protocol = sckTCPProtocol
    Winsock1.RemoteHost = eUrl.Host
    Winsock1.RemotePort = eUrl.Port
    Winsock1.Connect
   
    'wait for a connection
    While Not blnConnected
        DoEvents
    Wend
           
    'Send SMS to each Cell No from the List
    For i = 1 To MSFlexGrid1.Rows - 1
       
        strData = ""
        If Len(MSFlexGrid1.TextMatrix(i, 1)) = 10 Then      'When Cell No is enterd and 91 is present before it
       
          ' strData = sms_data & "mobileno=" & "91" & URLEncode(myNewArray(i, 1)) & "&" & "message=" & URLEncode(Text1.Text)
            strData = sms_data & "mobileno=" & "91" & URLEncode(MSFlexGrid1.TextMatrix(i, 1)) & "&" & "message=" & URLEncode(Text1.Text)
          '  strData = sms_data & "mobileno=" & "91" & URLEncode(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1)) & "&" & "message=" & URLEncode(Text1.Text)
            'URL encoded data is appended to the URI with a ?
            strUrl = eUrl.URI & "?" & strData
            Debug.Print strUrl
            'build the HTTP request in the form
            '
            '{REQ METHOD} URI HTTP/1.0
            'Host: {host}
            '{headers}
            '
            '{post data}
            strHTTP = strMethod & " " & strUrl & " HTTP/1.0" & vbCrLf
            strHTTP = strHTTP & "Host: " & eUrl.Host & vbCrLf
            strHTTP = strHTTP & strHeaders
            strHTTP = strHTTP & vbCrLf
            strHTTP = strHTTP & strPostData
           
            'send the HTTP request
            Winsock1.SendData strHTTP
            Debug.Print strHTTP
            lblStatus.Caption = "Sent : " & i & "/" & MSFlexGrid1.Rows - 1
           
        End If
       
    Next i
           
       
End Sub

for testing im using 3 phone numbers in the file but the above code is sending sms to only the first number in the file.. below is my excel file

Delivery 9594039909 Rohit
MCX 8446169139 Pratik
MCX 9405498981 Pritesh

i m printing the winsock response which i have pasted below


Code:

/SMSAPI.jsp?username=rohitdemo1&password=demo321&sendername=infoin&mobileno=919594039909&message=sdf
GET /SMSAPI.jsp?username=rohitdemo1&password=demo321&sendername=infoin&mobileno=919594039909&message=sdf HTTP/1.0
Host: promo.bulksmsnvoice.com


/SMSAPI.jsp?username=rohitdemo1&password=demo321&sendername=infoin&mobileno=918446169139&message=sdf
GET /SMSAPI.jsp?username=rohitdemo1&password=demo321&sendername=infoin&mobileno=918446169139&message=sdf HTTP/1.0
Host: promo.bulksmsnvoice.com


/SMSAPI.jsp?username=rohitdemo1&password=demo321&sendername=infoin&mobileno=919405498981&message=sdf
GET /SMSAPI.jsp?username=rohitdemo1&password=demo321&sendername=infoin&mobileno=919405498981&message=sdf HTTP/1.0
Host: promo.bulksmsnvoice.com


From Host: HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=442A31578352DCACF5C15B0795ADE6E5; Path=/; HttpOnly
Content-Type: text/html;charset=UTF-8
Content-Length: 61
Date: Sat, 02 Feb 2013 02:12:27 GMT
Connection: close





Your message is successfully sent to:919594039909

can anyone solve my problem

Viewing all articles
Browse latest Browse all 21185

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>