{"id":245,"date":"2015-10-06T09:31:53","date_gmt":"2015-10-06T06:31:53","guid":{"rendered":"http:\/\/blog.leodev.ru\/?p=245"},"modified":"2016-01-23T19:10:45","modified_gmt":"2016-01-23T16:10:45","slug":"get-%d0%b8-post-%d0%b7%d0%b0%d0%bf%d1%80%d0%be%d1%81%d1%8b-%d0%bd%d0%b0-%d1%81%d0%b5%d1%80%d0%b2%d0%b5%d1%80-%d1%81-android","status":"publish","type":"post","link":"https:\/\/leodev.ru\/blog\/android\/get-%d0%b8-post-%d0%b7%d0%b0%d0%bf%d1%80%d0%be%d1%81%d1%8b-%d0%bd%d0%b0-%d1%81%d0%b5%d1%80%d0%b2%d0%b5%d1%80-%d1%81-android\/","title":{"rendered":"GET \u0438 POST \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 Android"},"content":{"rendered":"<h2>GET<\/h2>\n<pre class=\"lang:java decode:true\">DefaultHttpClient hc = new DefaultHttpClient();  \r\nResponseHandler res = new BasicResponseHandler();  \r\nHttpGet http = new HttpGet(\"https:\/\/stat.farline.ua:9443\/index.cgi?user=user1&amp;passwd=1234\");  \r\n \r\n\/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430  \r\nString response = hc.execute(http, res);\r\n<\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u00a0\u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: &#171;<strong>\u0441\u0442\u0440\u043e\u043a\u0430 !&#187;\u2116;%?() \u0440\u0430\u0437<\/strong>&#171;, \u0442\u043e \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437<\/p>\n<pre class=\"lang:java decode:true \">URLEncoder.encode(\"\u0441\u0442\u0440\u043e\u043a\u0430 !\"\u2116;%?() \u0440\u0430\u0437\", \"UTF-8\")<\/pre>\n<p>\u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0430 \u0433\u0434\u0435 \u043f\u0440\u043e\u0431\u0435\u043b \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0430 &#171;%20&#187;<\/p>\n<h2>POST<\/h2>\n<pre class=\"lang:java decode:true \">HttpClient httpclient = new DefaultHttpClient();  \r\nHttpPost http = new HttpPost(\"http:\/\/site.ru\/api.php?\");  \r\n                      \r\nList nameValuePairs = new ArrayList(2);  \r\nnameValuePairs.add(new BasicNameValuePair(\"login\", \"user1\"));  \r\nnameValuePairs.add(new BasicNameValuePair(\"pswd\", \"1234\"));  \r\n \r\nhttp.setEntity(new UrlEncodedFormEntity(nameValuePairs));  \r\nString response = httpclient.execute(http, new BasicResponseHandler());<\/pre>\n<p><!--more--><\/p>\n<h2>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438<\/h2>\n<pre class=\"lang:java decode:true \">http.setHeader(\"Authorization\", \"Basic \"+Base64.encodeToString(\"login:password\".getBytes(), Base64.NO_WRAP));<\/pre>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0447\u0442\u043e \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430\u0434\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/startandroid.ru\/ru\/uroki\/vse-uroki-spiskom\/149-urok-86-asynctask-znakomstvo-neslozhnyj-primer\">AsyncTask<\/a> \u0438\u043b\u0438 <a href=\"http:\/\/startandroid.ru\/ru\/uroki\/vse-uroki-spiskom\/274-urok-135-loader-loadermanager-asynctaskloader.html\">AsyncTaskLoader<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GET DefaultHttpClient hc = new DefaultHttpClient(); ResponseHandler res = new BasicResponseHandler(); HttpGet http = new HttpGet(&#171;https:\/\/stat.farline.ua:9443\/index.cgi?user=user1&amp;passwd=1234&#8243;); \/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 String response = hc.execute(http, res); \u0415\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u00a0\u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: &#171;\u0441\u0442\u0440\u043e\u043a\u0430 !&#187;\u2116;%?() \u0440\u0430\u0437&#171;, \u0442\u043e \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 URLEncoder.encode(&#171;\u0441\u0442\u0440\u043e\u043a\u0430 !&#187;\u2116;%?() \u0440\u0430\u0437&#187;, &#171;UTF-8&#187;) \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0430 \u0433\u0434\u0435 \u043f\u0440\u043e\u0431\u0435\u043b \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 &hellip; <a href=\"https:\/\/leodev.ru\/blog\/android\/get-%d0%b8-post-%d0%b7%d0%b0%d0%bf%d1%80%d0%be%d1%81%d1%8b-%d0%bd%d0%b0-%d1%81%d0%b5%d1%80%d0%b2%d0%b5%d1%80-%d1%81-android\/\" class=\"more-link\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435<span class=\"screen-reader-text\"> \u00abGET \u0438 POST \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 Android\u00bb<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":248,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[73,76,77],"class_list":["post-245","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","tag-android","tag-http","tag-77"],"_links":{"self":[{"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/posts\/245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/comments?post=245"}],"version-history":[{"count":6,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":312,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/posts\/245\/revisions\/312"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/media\/248"}],"wp:attachment":[{"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}