logo logo

The next-generation blog, news, and magazine theme for you to start sharing your stories today!

The Blogzine

Save on Premium Membership

Get the insights report trusted by experts around the globe. Become a Member Today!

View pricing plans

New York, USA (HQ)

750 Sing Sing Rd, Horseheads, NY, 14845

Call: 469-537-2410 (Toll-free)

hello@blogzine.com
.Net

[VB.Net] Pusher API Posted Nofitication On Web

Lấy theo ý tưởng của NamCoder về bài viết "Hướng dẫn Pusher - Viết ứng dụng thời gian thực" mình đã lên ý tưởng và phát triển nó ra thành Client sử dụng trên Windows , Nhìn vậy thôi chứ mìn…

avatar
Hung.Pro.VN

Developer Windows


  • 12/07/2015
  • Views
[VB.Net] Pusher API Posted Nofitication On Web

Lấy theo ý tưởng của NamCoder về bài viết "Hướng dẫn Pusher - Viết ứng dụng thời gian thực" mình đã lên ý tưởng và phát triển nó ra thành Client sử dụng trên Windows , Nhìn vậy thôi chứ mình dùng hàm HTTP Request

Code VB.NET do mình viết

Dim postData As String = "http://domain.com/execute.php&message=" & TextBox1.Text & "&username=" & TextBox3.Text
Dim tempCookies As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)

Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://pusher.16mb.com/execute.php"), HttpWebRequest)
postReq.Method = "POST"
postReq.KeepAlive = True
postReq.CookieContainer = tempCookies
postReq.ContentType = "application/x-www-form-urlencoded"
postReq.Referer = "http://pusher.16mb.com/user.html"
postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
postReq.ContentLength = byteData.Length

Dim postreqstream As Stream = postReq.GetRequestStream()
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse

postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
tempCookies.Add(postresponse.Cookies)
logincookie = tempCookies
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
Dim thepage As String = postreqreader.ReadToEnd
TextBox3.Enabled = True

Nhìn vào code bên trên chắc các bạn biết thêm những gì rồi: 2 Textbox
Hoặc các bạn có thể Download Full Code ở bên dưới :)

Xem Clip để hiểu rỏ hơn:


Download Code VB.Net Download API Pusher

Related post


avatar

Hung.Pro.VN

Nhà thiết kế Web
View Articles

Tôi là admin trang Hung.Pro.VN là một người có đam mê với Blogspot, kinh nghiệm 5 năm thiết kế ra hàng trăm mẫu Template blogpsot như" Bán hàng, bất động sản, landing page, tin tức...

Nhận xét

  1. Người ngoài nghề chả biết đây là cái gì! (-, - )

    Trả lờiXóa
    Trả lời
    1. Hi. Học lập trình đi NAM ^_^. Sau này sẽ hửu ích lắm đó :)

      Xóa

Đăng nhận xét

Share this article