[VB.Net] Pusher API Posted Nofitication On Web

[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

Hướng dẫn bình luận

Mọi người để lại bình luận góp ý, nhận xét về những bài viết mà mình chia sẽ văn minh lịch sự hay kích động, Không spam, không chèn link quảng cáo, bán hàng, Không sử dụng từ ngữ thô tục, xúc phạm, kích động, Link chỉ được phép khi thực sự liên quan đến nội dung bài viết, Không mạo danh người khác hoặc sử dụng email giả, Bình luận vi phạm sẽ bị xóa không cần thông báo trước.
Mọi người lưu ý răng, nếu muốn chia sẽ code ở bình luần thì cần mã hóa code trước khi bỏ vào khung nhé. :)
⑴ Chèn ℂ𝕤𝕤 theo mẫu : [pre css] ℂ𝕤𝕤 [/pre]
⑵ Chèn ℍ𝕥𝕞𝕝 theo mẫu : [pre html] ℍ𝕥𝕞𝕝 [/pre]
⑶ Chèn 𝕁𝕒𝕧𝕒𝕤𝕔𝕣𝕚𝕡𝕥 theo mẫu : [pre js] 𝕁𝕒𝕧𝕒𝕤𝕔𝕣𝕚𝕡𝕥 [/pre]

🖼️ Chèn 𝕀𝕞𝕒𝕘𝕖 theo mẫu : [img] 𝕃𝕚𝕟𝕜 𝕀𝕞𝕒𝕘𝕖 [/img]
🎞️ Chèn Video 𝕐𝕠𝕦𝕥𝕦𝕓𝕖 theo mẫu : [youtube] 𝕃𝕚𝕟𝕜 𝕪𝕠𝕦𝕥𝕦𝕓𝕖 [/youtube]

2 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

@Bloggers Community

@Catalogics

CSS (31) Google (7)

@Total Pageviews