Connection.Response response = Jsoup.connect("http://habrahabr.ru/json/favorites/")
.header("Content-Type","application/x-www-form-urlencoded;charset=UTF-8")
.header("Accept", "*/*")
.header("Accept-Encoding", "gzip,deflate,sdch")
.header("Accept-Language", "ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4")
.header("X-Requested-With", "XMLHttpRequest")
.ignoreContentType(true)
.cookie(User.PHPSESSION_ID, cookie1)
.cookie(User.HSEC_ID, cookie2)
.data("tt", targetType)
.data("ti", Integer.toString(targetId))
.data("action", "add")
.method(Connection.Method.POST)
.execute();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://habrahabr.ru/json/favorites/");
httppost.setHeader("Content-type", "application/x-www-form-urlencoded");
httppost.setHeader("Accept", "application/json");
httppost.setHeader("X-Requested-With", "XMLHttpRequest");
httppost.addHeader("Cookie", " PHPSESSID=" + cookie1 + "; hsec_id=" + cookie2);
List<NameValuePair> params = new ArrayList<NameValuePair>(3);
params.add(new BasicNameValuePair("tt", targetType));
params.add(new BasicNameValuePair("ti", Integer.toString(targetId)));
params.add(new BasicNameValuePair("action", "add"));
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
//Execute and get the response.
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
// Обработка ответа