You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by manoj patidar <ma...@yahoo.com> on 2010/10/01 06:34:53 UTC

Facebook login fails

Hi All,

I am login to facebook site using httpclient, it logs in 70% of times but
fails 30% of time, i am not able to find the solution, any help would be
greatly appreciated.

The problem with the code is 
1)some time it logs in and redirect to home.php
2)some time login fails.

is there any thing i am not adding. 

the code i used to connect is 

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		HttpClient httpclient = new HttpClient(); 
		
		httpclient.getHostConfiguration().setProxy("10.30.250.4", 8080);
		try
		{
		   HttpMethod httpMethod = new
GetMethod("http://www.facebook.com/login.php"); 
		   //httpget("http://www.facebook.com/login.php"); 
		 
		httpclient.executeMethod(httpMethod);
		int statuscode = httpMethod.getStatusCode();

			 String date = "2011" + "/" + "01" + "/" + "01";
		     java.util.Date utilDate = null;

		      SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
		      utilDate = formatter.parse(date);
		      

	    HttpMethod httpPost = new
PostMethod("http://www.facebook.com/login.php");
 	    NameValuePair[] nv=new NameValuePair[2];; 
		nv[0] = new NameValuePair("email", "************************"); 
		nv[1] = new NameValuePair("pass", "************************"); 
		((PostMethod)httpPost).setRequestBody(nv);
		
		httpclient.executeMethod(httpPost);
		int statuscode1 = httpPost.getStatusCode();
		
		
        Header locationHeader = httpPost.getResponseHeader("location");
        String redirectLocation="";
        if (locationHeader != null) 
        {
        	redirectLocation = locationHeader.getValue(); 

        }	
		 System.out.println("redirect location"+redirectLocation); 

		httpMethod.releaseConnection();
	    httpPost.releaseConnection();
		
		} catch(Exception e){
	     e.printStackTrace();
		} 
	}


any help would be appreciated

-- 
View this message in context: http://old.nabble.com/Facebook-login-fails-tp29854635p29854635.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Facebook login fails

Posted by sebb <se...@gmail.com>.
On 1 October 2010 05:34, manoj patidar <ma...@yahoo.com> wrote:
>
> Hi All,
>
> I am login to facebook site using httpclient, it logs in 70% of times but
> fails 30% of time, i am not able to find the solution, any help would be
> greatly appreciated.

It would be easier for others to provide help if you provided:
- the version of HttpClient that you are using
- the error message that you get when the login fails.

> The problem with the code is
> 1)some time it logs in and redirect to home.php
> 2)some time login fails.
>
> is there any thing i am not adding.
>
> the code i used to connect is
>
>        /**
>         * @param args
>         */
>        public static void main(String[] args) {
>                // TODO Auto-generated method stub
>
>                HttpClient httpclient = new HttpClient();
>
>                httpclient.getHostConfiguration().setProxy("10.30.250.4", 8080);
>                try
>                {
>                   HttpMethod httpMethod = new
> GetMethod("http://www.facebook.com/login.php");
>                   //httpget("http://www.facebook.com/login.php");
>
>                httpclient.executeMethod(httpMethod);
>                int statuscode = httpMethod.getStatusCode();
>
>                         String date = "2011" + "/" + "01" + "/" + "01";
>                     java.util.Date utilDate = null;
>
>                      SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
>                      utilDate = formatter.parse(date);
>
>
>            HttpMethod httpPost = new
> PostMethod("http://www.facebook.com/login.php");
>            NameValuePair[] nv=new NameValuePair[2];;
>                nv[0] = new NameValuePair("email", "************************");
>                nv[1] = new NameValuePair("pass", "************************");
>                ((PostMethod)httpPost).setRequestBody(nv);
>
>                httpclient.executeMethod(httpPost);
>                int statuscode1 = httpPost.getStatusCode();
>
>
>        Header locationHeader = httpPost.getResponseHeader("location");
>        String redirectLocation="";
>        if (locationHeader != null)
>        {
>                redirectLocation = locationHeader.getValue();
>
>        }
>                 System.out.println("redirect location"+redirectLocation);
>
>                httpMethod.releaseConnection();
>            httpPost.releaseConnection();
>
>                } catch(Exception e){
>             e.printStackTrace();
>                }
>        }
>
>
> any help would be appreciated
>
> --
> View this message in context: http://old.nabble.com/Facebook-login-fails-tp29854635p29854635.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org