HTTP Webrequest帖子(登录YAhooMail) [英] HTTP Webrequest post (Login to YAhooMail)

查看:67
本文介绍了HTTP Webrequest帖子(登录YAhooMail)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我终于使用httpwebrequest登录yahoomail。

我现在的问题是如何设置一个消息框说我的登录成功与否。

for现在我尝试使用正确的用户名登录并传递。



希望有人可以帮助我。



这是我到目前为止的代码。



I finally logged in to yahoomail using httpwebrequest.
my problem now is how I am going to put a messagebox saying my log in is successful or not.
for now im trying to login using a correct username and pass.

Hope someone can help me about it.

Here's my code so far.

Imports System.IO
Imports System.Net
Imports System.Text

Public Class Form1

    Dim loginCoockie As New CookieContainer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim uName As String = TextBox1.Text
        Dim pWord As String = TextBox2.Text

        Label1.Text = "Trying to Log In"

        Dim postData As String = ".tries=1&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=us&.bypass=&.partner=&.u=7jebrpt78q79h&.v=0&.challenge=a5PSc8KUgQ7.sU0VVUE9JsdHOosB&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fmail.yahoo.com&.pd=ym_ver%3D0%26c%3D%26ivt%3D%26sg%3D&.ws=1&.cp=0&pad=5&aad=6&login=" & uName & "&passwd=" & pWord & "&.save=&passwd_raw="
        Dim tempCookies As New CookieContainer
        Dim encoding As New UTF8Encoding
        Dim byteData As Byte() = encoding.GetBytes(postData)


        Dim postRequest As HttpWebRequest = DirectCast(WebRequest.Create("https://login.yahoo.com/config/login"), HttpWebRequest)
        postRequest.Method = "POST"
        postRequest.KeepAlive = True
        postRequest.CookieContainer = tempCookies
        postRequest.ContentType = "application/x-www-form-urlencoded"
        postRequest.Referer = "https://login.yahoo.com/config/login"
        postRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0a2) Gecko/20110613 Firefox/6.0a2"
        postRequest.ContentLength = byteData.Length


        Dim postReqStream As Stream = postRequest.GetRequestStream
        postReqStream.Write(byteData, 0, byteData.Length)
        postReqStream.Close()

        Dim postResponse As HttpWebResponse

        postResponse = DirectCast(postRequest.GetResponse(), HttpWebResponse)
        tempCookies.Add(postResponse.Cookies)
        loginCoockie = tempCookies

        Dim postReqReader As New StreamReader(postResponse.GetResponseStream())

 End Sub







我真的很新。



这是我的源代码:



http: //www.mediafire.com/?klkdtigu34qaek2





希望有人可以帮我解决这个问题..



谢谢..




I am really new to it.

Here's my source code:

http://www.mediafire.com/?klkdtigu34qaek2


Hope can some one help me about it..

Thanks..

推荐答案

您是否理解登录失败的通知形式是在服务器端完全定义的?您只能通过分析 postResponce 的内容来确定它们。



尝试执行以下操作。使用常规Web浏览器登录到Yahoo并尝试手动执行有效和无效的登录。弄清楚如何显示登录失败。在运行时,从 postResponce 中读取并尝试确定如何演示登录失败。在你的代码中使用它。



-SA
Do you understand that the form of notification of the login failure is completely defined one the server side? You can only figure it our by analyzing the content of postResponce.

Try to do the following. Log to Yahoo using a regular Web browser and try to do valid and invalid logins manually. Figure out how failure to log in is manifested. During runtime, read from postResponce and try to identify how the failure of login is demonstrated. Use it in your code.

—SA


我的电子邮件地址和密码一直很好2周前。发生了什么事?
My email address and password was fine until 2 weeks ago.what happened?


这篇关于HTTP Webrequest帖子(登录YAhooMail)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆