Hi Oleg:

Thanks for your reply. Two days ago I tried the FormLoginDemo, but after I saw your 
e-mail I tried again and got the following response, with my Sun Developer Id and 
password :

===============================================================================================================

Login form get: HTTP/1.1 200 OK
Initial set of cookies:
None
Apr 28, 2004 10:05:24 AM org.apache.commons.httpclient.HttpMethodBase 
processRedirectResponse
INFO: Redirect requested but followRedirects is disabled
Login form post: HTTP/1.1 302 Moved Temporarily
Logon cookies:
- JDC=5719750140229660595
- JSESSIONID=developer.java.sun.com-e7b9%253A408fba23%253Af8cfb4dd3166b6ce
- SessionCredentials=5213651892774654901
Redirect target: http://developer.java.sun.com/index.html
Apr 28, 2004 10:05:24 AM org.apache.commons.httpclient.HttpMethodBase 
checkValidRedirect
WARNING: Error getting URI host
org.apache.commons.httpclient.HttpException: Redirect from host developer.java.sun.com 
to java.sun.com is not supported
        at 
org.apache.commons.httpclient.HttpMethodBase.checkValidRedirect(HttpMethodBase.java:1243)
        at 
org.apache.commons.httpclient.HttpMethodBase.processRedirectResponse(HttpMethodBase.java:1191)
        at 
org.apache.commons.httpclient.HttpMethodBase.isRetryNeeded(HttpMethodBase.java:977)
        at 
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1095)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:675)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:529)
        at FormLoginDemo.main(FormLoginDemo.java:124)
Apr 28, 2004 10:05:24 AM org.apache.commons.httpclient.HttpMethodBase 
processRedirectResponse
WARNING: Invalid Redirect URI from: http://developer.java.sun.com:80/index.html to: 
http://java.sun.com/
Redirect: HTTP/1.1 302 Moved Temporarily

===============================================================================================================

The probelm with Yahoo login is even harder to understand, it seems Yahoo redirects 
several times, and it requires cookies, I tried the following lines, but it won't work 
:

===============================================================================================================
    System.getProperties().put("java.protocol.handler.pkgs", "HTTPClient");
    
    String url="https://login.yahoo.com/config/login";;
//    String url="http://f1.pg.briefcase.yahoo.com/";;
    HttpClient client = new HttpClient();
    HttpMethod method = new GetMethod(url);

    try
    {
//      URL url=new URL("https://login.yahoo.com/config/login";);    
/*      String Msg_Out=".fUpdate=1\n"+
                     ".tries=1\n"+
                     ".done=http://f1.pg.briefcase.yahoo.com/\n"+
                     ".src=bc\n"+
                     ".intl=us\n"+
                     "login=javamr\n"+
                     "passwd=javatest\n"+
                     "submit=Login";

      String Msg_Out=".fUpdate=1"+
                     "&.tries=1"+
                     "&.done=http://f1.pg.briefcase.yahoo.com/"+
                     "&.src=bc"+
                     "&.intl=us"+
                     "&login=javamr"+
                     "&passwd=javatest"+
                     "&submit=Login";

//      WriteFile Write_File=new WriteFile(url,Msg_Out);
//      taText.append(Write_File.Text_In.toString());
//      NM_Lib.Display_HTML_In_Browser(Write_File.Text_In.toString());

//      method.setQueryString(Msg_Out);
*/       
      NameValuePair N_V_P[]= { new NameValuePair(".fUpdate","1"),
                               new NameValuePair(".tries","1"),
                               new 
NameValuePair(".done","http://f1.pg.briefcase.yahoo.com/";),
                               new NameValuePair(".src","bc"),
                               new NameValuePair(".intl","us"),
                               new NameValuePair("login","javamr"),
                               new NameValuePair("passwd","javatest"),
                               new NameValuePair("submit","Login")
                             };
     
      method.setQueryString(N_V_P);
      client.executeMethod(method);
    
    }
    catch (Exception e) { System.out.println(e.toString()); }
       
    String responseBody = method.getResponseBodyAsString();
    method.releaseConnection();
//    NM_Lib.Display_HTML_In_Browser(responseBody);
  }

===============================================================================================================

For testing purpose I've created a Yahoo account ( Id : javamr / Password : javatest 
), the result of the above code is another login page, I wonder if you can help my to 
login and download a page from Yahoo Briefcase. Thanks.

Frank


-----Original Message-----
From: Oleg Kalnichevski [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 6:25 PM
To: Commons HttpClient Project
Subject: Re: Yahoo login with Httpclient


Frank,
You need to use so called form-based login. Have a look at this sample
application:

http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/FormLoginDemo.java?rev=1.1.2.1&only_with_tag=HTTPCLIENT_2_0_BRANCH&view=markup

If it does not cut it for you, let me know. I may try to quickly hack it
up for you (provided I do not get stamped with work (the one that helps
me pay the bills I mean))

Oleg


On Wed, 2004-04-28 at 00:08, Min (Frank) Ni wrote:
> Hi:
> 
> I've been trying to use Httpclient to programmatically login to Yahoo, but I am not 
> sure how to do it right, I've tried to follow the sample tutorials and nothing 
> seemed to work for me, I've also searched the web for answers, but failed, it seems 
> to me that Httpclient is the closest match for what I am looking for, can somebody 
> please help me ? 
> 
> Some sample code of how to use Httpclient to login to Yahoo would be very helpful, I 
> imagine if I supply username and password to it, I would get a page showing I'm 
> logged in, I am trying to update my Yahoo Briefcase and Yahoo Geocities pages with 
> my program. Is it possible to do that with Httpclient ? Thanks for any help.
> 
> Frank
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to