How to pass data to a url

therealzeta

Member
Joined
Aug 9, 2008
Messages
19
Programming Experience
5-10
Hello, I am doing a softwear that send sms messeges to cel phone thru a url I was given by a provider. He told me to use the address he gave me on my webrowser with the info needed. (for example, www.smsmessage.com?cel='Celphone'&message='texto'. I am searching a way to do this without having to open the webrowser. Could I use this code?? I could do it with out having to open the webrowser.

Dim request As WebRequest = WebRequest.Create("http://www.contoso.com/default.html")
request.Credentials = CredentialCache.DefaultCredentials
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)

I dont have to receive any information back from the webserver. Just to post the info needed to send the messages.

Hope some one can help me.

Thx
 
Yes, you can pass the querystring parameters directly through the url of the request.
 
Thanks, but i tried it but it didnt work. I test the url i am passing and it works if i put it in the webrowser. Do u have any idea of what is going on??

Thanks again
 
No, but perhaps you have? What status code and response do you get?
 
VB.NET:
Public Function EnvioSMS(ByVal cel1 As String, ByVal texto As String) As Boolean
        Try
            Dim theURL As String
            Dim a, b As String
            theURL = "http://smsc.ilogica.com/simpacsys01/?telefono=" & cel1 & "&texto=" & texto & "&userid=4679"

            Dim request As WebRequest = WebRequest.Create(theURL)
            request.Credentials = CredentialCache.DefaultCredentials
            Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)

            a = response.StatusCode
            b = response.StatusDescription
            EnvioSMS = True


        Catch ex As Exception
            EnvioSMS = False
        End Try

    End Function

this is the function i used to send the messages. Those are the values I received from the request. The string I am passing to the function, works ok if I paste it on the webrowser.

?response.StatusCode
OK {200}
?response.StatusDescription
"OK"

hope u can help, it is my first .net application
 
OK status code means the request was accepted by Http server, but that doesn't mean the application request was processed. Are you sure you have sent the request in correct format, is the query parameter values really not supposed to be quoted? So what about the response, what is the content of the page you are served when making that request? See help about how to read it: HttpWebResponse.GetResponseStream Method (System.Net)
 
I was reading the link u send me. The only thing I could find is "You must call either the Stream..::.Close or the HttpWebResponse..::.Close method to close the stream and release the connection for reuse".

On the other hand I was checking on internet the diference between Post y Get. I must use GET but I dont mention it in the code. Could it be the problem??? none of this I have tested cause the server has problem. Hope the monday I can try all of this and finally find the solution.

Thx for ur time
 
GET is default, you don't need to specify it.

You didn't read the VB.Net code example? It tells how to read the text the server is sending in reponse to your request. It is usually the same Html source that you get when using a webbrowser to do the same action. In this case, since the request apparently fails for you, you'd be interested in reading it to see if some kind of message is returned telling what is wrong with your request.
 
I already test the code and I received the answer from the server. But, when i use the iinternet explorer, after sending the url, what the internet display is Ok: Mensaje enviado, Acuse: 8E3D6B6D (Message Sent) and the sms is sent. With my application I received all this but i dont see the text showing that the sms has been sent. It is like my application dont press the enter. I havent contact my sms provider, i hope they can help me, cause I am doing what everybody does in any example i see, but it doesnt work.

thx

HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
  "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>INTERLOGICA SMS CENTER</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="keywords" content="php, apache, web">
<meta name="robots" content="index,follow">
<meta name="description" content="Electronics & Computer Network Design">
<meta name="generator" content="Domain Direct Forwarding">
</head>
<frameset framespacing="0" rows="100%,*" cols="100%" frameborder="no" border="0">
  <frame name="DDIRECTXYZZY2" scrolling="auto" src="http://201.120.133.35:99/simpacsys01/?telefono=4431119515&texto=Prueba&userid=1234" noresize>
  <frame name="DDIRECTXYZZY" scrolling="no" noresize>
  <noframes>
    <h1><a href="http://201.120.133.35:99/simpacsys01/?telefono=4431119515&texto=Prueba&userid=1234">smsc.ilogica.com</a></h1>
    <p>Please <a href="http://201.120.133.35:99/simpacsys01/?telefono=4431119515&texto=Prueba&userid=1234">click here</a> to view the non-framed version.</p>
    <hr>
    <p>Electronics & Computer Network Design</p>
  </noframes>
</frameset>
</html>
 
If that request doesn't cause the sms to be sent it must be the url of the framed page you receive that cause it. If you load the smsc.ilogica url in browser and look at the source code you see the exact same source as you posted. You see the url http://201... for the frameset page that the browser would normally load for that address, if you request this url you get the same "message sent" confirmation html page as response.
VB.NET:
Dim url As String = "http://201.120.133.35:99/simpacsys01/?telefono=4431119515&texto=Prueba&userid=1234"
Dim web As New Net.WebClient
MsgBox(web.DownloadString(url))
 
thankssssssssss, I already understand what was happening. What really send the sms is the frameset. Now that i set the right address, i already receive the Ok message. It is the first time I deal with a webpage and I lack of experience with them.Thanks again pal.

:D
 

Latest posts

Back
Top