Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Smarty 1.13 KB | None | 0 0
  1. Private Function SendData(ByVal PostData As String, ByVal Site As String) As String      
  2.         Dim Request As HttpWebRequest = DirectCast(WebRequest.Create(Site), HttpWebRequest)
  3.         Request.Method = "POST"
  4.         Request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"
  5.         Request.ContentType = "application/x-www-form-urlencoded"
  6.         Request.AllowAutoRedirect = True
  7.         Request.ServicePoint.Expect100Continue = False
  8.         Request.ContentLength = PostData.Length
  9.         Using ReqStream As Stream = Request.GetRequestStream()
  10.             Dim Encoding As New UTF8Encoding()
  11.             Dim PostBytes As Byte() = Encoding.GetBytes(PostData)
  12.             ReqStream.Write(PostBytes, 0, PostBytes.Length)
  13.         End Using
  14.         Dim Result As String = String.Empty
  15.         Using Response As HttpWebResponse = Request.GetResponse()
  16.             Using RespStream As Stream = Response.GetResponseStream()
  17.                 Using Reader As New StreamReader(RespStream)
  18.                     Result = Reader.ReadToEnd()
  19.                 End Using
  20.             End Using
  21.         End Using
  22.         Return Result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement