Cupcake ipsum dolor sit amet I love chupa chups.
protected Void doInBackground(Void ...voids) {
    		HttpClient httpClient = new DefaultHttpClient();
            HttpPost request = new HttpPost("http://en.wikipedia.org/w/api.php");
            CookieStore cookieStore = new BasicCookieStore();
            HttpContext localContext = new BasicHttpContext();
            localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
            httpClient.getParams().setParameter(
                    ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);

            
            List postParameters;
            JSONObject jsonObject = null;

            try {
            	postParameters = getPostParameters(new BasicNameValuePair("action", "login"), new BasicNameValuePair("lgname", URLEncoder.encode(lgname, "UTF-8"))
    					 , new BasicNameValuePair("lgpassword", URLEncoder.encode(lgpassword, "UTF-8")), new BasicNameValuePair("format", "json"));
    		} catch (UnsupportedEncodingException e1) {
    			System.err.print("Cannot encode url");
    			e1.printStackTrace();
    			postParameters = null;
    		}
            try {
            	 
				UrlEncodedFormEntity entity = new UrlEncodedFormEntity(postParameters, HTTP.UTF_8);
            	request.setEntity(entity);
            	HttpResponse response = httpClient.execute(request, localContext);
            	jsonObject = getJSON(response);
            	System.out.println(jsonObject.toString() + " I am here 0");
            	 
            } catch (UnsupportedEncodingException e) {
    			e.printStackTrace();
    		} catch (ClientProtocolException e) {
    			e.printStackTrace();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
            
            
            try {
            	if(jsonObject.getJSONObject("login").getString("result").equals("NeedToken")) {
            		try {
						System.out.println(jsonObject.getJSONObject("login").getString("token") + " I am here 1");
            			postParameters = getPostParameters(new BasicNameValuePair("action", "login"), new BasicNameValuePair("lgname", URLEncoder.encode(lgname, "UTF-8"))
						, new BasicNameValuePair("lgpassword", URLEncoder.encode(lgpassword, "UTF-8")), new BasicNameValuePair("lgtoken", jsonObject.getJSONObject("login").getString("token"))
						, new BasicNameValuePair("format", "json"));
						UrlEncodedFormEntity entity = new UrlEncodedFormEntity(postParameters, HTTP.UTF_8);
						request.setEntity(entity);
						HttpResponse response = httpClient.execute(request, localContext);
						jsonObject = getJSON(response);
						System.out.println(jsonObject.getJSONObject("login").toString() + " I am here 2");
						System.out.println(cookieStore.toString() + " I am here 3");	
            		} catch (UnsupportedEncodingException e) {
						e.printStackTrace();
					} catch (ClientProtocolException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}
            	}
			} catch (JSONException e) {
				e.printStackTrace();
			}
             
            return null;
    	}
    }
New Relic