HTTPWebRequest Problem

J

Jeremy

I am attempting to use T-Mobile's web site to send SMS messages. (I
couldn't find a free web service for this purpose...if you know of a
free one compatible with T-mobile let me know.) Using examples from
multiple sources, I have come up with the following function (VB.net
1.1):

Private Function SendTMobileSMS(ByVal strPhoneNumber As String,
ByVal strMessage As String, ByVal strFrom As String)

Dim strURL As String =
"https://wmg.tmomail.net/customer_site/jsp/messaging_lo.jsp"
Dim strPostData As String

strPostData = "min=" & HttpUtility.UrlEncode(strPhoneNumber)
'To
strPostData += "&require_sender=" &
HttpUtility.UrlEncode(strFrom) ' From
strPostData += "&text=" & HttpUtility.UrlEncode(strMessage) '
Phone Number
strPostData += "&msgTermsUse=" & HttpUtility.UrlEncode("Y")
'Agree to terms

Dim myPostEncoding As Byte() =
System.Text.Encoding.GetEncoding(1252).GetBytes(strPostData)

Dim myRequest As HttpWebRequest =
CType(WebRequest.Create(strURL), HttpWebRequest)
myRequest.Method = "POST"
myRequest.ContentType = "application/x-www-form-urlencoded"
myRequest.ContentLength = myPostEncoding.Length
myRequest.CookieContainer = New CookieContainer


Dim myStream As IO.Stream = myRequest.GetRequestStream
myStream.Write(myPostEncoding, 0, myPostEncoding.Length)
myStream.Flush()
myStream.Close()

End Function

The request results in a response indicating an error has occured. The
page is fairly simple...3 text boxes, a check box, and a send message
button. I did notice potentially two difficulties however...the web
page has 3 forms, and the send message buttun is not actually a submit
button but an image button. I'm not sure what I am doing wrong here.
This in advance for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top