我使用的WebRequest张贴到重定向我的页面我真的需要张贴到登录页面。

我怎样才能发布到这个页面,我被重定向到?这里是代码:

***** NEW STUFF *****

下面我发布到登录页面后发生了什么: GET /config/validate?.src=flickr&.pc=5134&.scrumb=6l14Ni2Pz3j&.pd=c%3DE0.GahOp2e4MjkX.5l2HgAoLkpmyPvccpVM-&.intl=us&.done=http%3A%2F%2Fwww.flickr.com%2Fsignin %2Fyahoo%2F%3Fredir%3D%252Fpeople%252Flindieb68%252Frelationship%252F

GET /登入/雅虎/?导向=%2Fpeople%2Flindieb68%2Frelationship%

GET /cookie_check.gne?pass=%2Fpeople%2Flindieb68%2Frelationship%2F&fail=register_cookies.gne

GET /人/ lindieb68 /关系/

最后一个是我需要点击一个按钮。我是不是应该通过所有这些GET和收集饼干?晚饭后,我会尝试,让你知道。我喜欢这种感觉会工作。我将在一点点更新。

        private CookieContainer LoginYahoo(CookieContainer cookies)
        {
            string appURL = "https://login.yahoo.com/config/login?.src=flickr&.pc=5134&.scrumb=0&.pd=c%3DE0.GahOp2e4MjkX.5l2HgAoLkpmyPvccpVM-&.intl=us&.done=https%3A%2F%2Flogin.yahoo.com%2Fconfig%2Fvalidate%3F.src%3Dflickr%26.pc%3D5134%26.scrumb%3D0%26.pd%3Dc%253DE0.GahOp2e4MjkX.5l2HgAoLkpmyPvccpVM-%26.intl%3Dus%26.done%3Dhttp%253A%252F%252Fwww.flickr.com%252Fsignin%252Fyahoo%252F%253Fredir%253D%25252Fpeople%25252Flindieb68%25252Frelationship%25252F&rl=1";
            string strPostData = ".tries=1&.src=flickr&.md5=&.hash=&.js=&.last=&promo=&.intl=us&.bypass=&.partner=&.u=0delt5h5l4df0&.v=0&.challenge=3DZF0DFFqdE0m.9MWnCq6LjUZ9gV&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=1&.chkP=Y&.done=https%3A%2F%2Flogin.yahoo.com%2Fconfig%2Fvalidate%3F.src%3Dflickr%26.pc%3D5134%26.scrumb%3D0%26.pd%3Dc%253DE0.GahOp2e4MjkX.5l2HgAoLkpmyPvccpVM-%26.intl%3Dus%26.done%3Dhttp%253A%252F%252Fwww.flickr.com%252Fsignin%252Fyahoo%252F%253Fredir%253D%25252Fpeople%25252Flindieb68%25252Frelationship%25252F&.pd=flickr_ver%3D0%26c%3DE0.GahOp2e4MjkX.5l2HgAoLkpmyPvccpVM-%26ivt%3D%26sg%3D&login=loginName&passwd=Password&.persistent=y&.save=Sign+In";

            // Setup the http request.
            HttpWebRequest wrWebRequest = WebRequest.Create(appURL) as
            HttpWebRequest;
            wrWebRequest.Method = "POST";
            wrWebRequest.ContentLength = strPostData.Length;
            wrWebRequest.ContentType = "application/x-www-form-urlencoded";
            CookieContainer cookieContainer = cookies;
            wrWebRequest.CookieContainer = cookieContainer; 

            // Post to the login form.
            StreamWriter swRequestWriter = new
            StreamWriter(wrWebRequest.GetRequestStream());
            swRequestWriter.Write(strPostData);
            swRequestWriter.Close();

            // Get the response.
            HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();

            // Read the response
            StreamReader srResponseReader = new
            StreamReader(hwrWebResponse.GetResponseStream());
            string strResponseData = srResponseReader.ReadToEnd();
            srResponseReader.Close();

            //YOU ARE NOW LOGGED IN TO YAHOO!
            //NEED TO POST AGAIN TO WHAT hwrWebResponse RETURNS
            ShowInBrowser(strResponseData);
            return cookieContainer;
        }
有帮助吗?

解决方案

收集所有来自作为其中的至少一个先前(登录)反应的饼干会告诉你已经登录雅虎的饼干,然后包括你的文章requst到目标页面,或任何其他的饼干与雅虎相互作用。

修改:查看此文章收集和重新使用的cookie的完整代码示例,点击 http://blogs.msdn.com/dgorti/archive/ 2005/08/16 / 452347.aspx

其他提示

设置AllowAutoRedirect为true您HttpWebRequest的实例。

这是越来越复杂。

在短答案似乎是收集饼干。出于某种原因,我在虽然这样做会失败。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top