{"id":249961,"date":"2015-02-07T20:02:02","date_gmt":"2015-02-07T16:02:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=249961"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=249961","title":{"rendered":"<span class=\"post_title\">Flickr API \u0432 Android App. \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440\u0430\u043b\u044e\u0434\u0438!<\/p>\n<p>  \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Flickr API \u0432 Android \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Flickr. \u041a\u043e\u0442\u043e\u0440\u0443\u044e \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432 \u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h4>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c API Key, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0438\u0445 \u0446\u0435\u043b\u044f\u0445, \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"https:\/\/www.flickr.com\/services\/apps\/create\/noncommercial\/?\">Create an App<\/a>. <\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/ad4\/d77\/7ae\/ad4d777aed3e4e59a0629c6306a4e12a.jpg\"\/><\/p>\n<p>  \u041d\u0430\u0441 \u043f\u0440\u043e\u0441\u044f\u0442 \u0432\u0432\u0435\u0441\u0442\u0438 \u00ab\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u00bb, \u00ab\u0426\u0435\u043b\u044c\u00bb \u0438 \u00ab\u0421\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438\u00bb, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c API Key \u0438 API Secret. \u041e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b \u043d\u0430\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443.<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/52f\/499\/9dd\/52f4999dd727413fbfc854abfcff8d0f.jpg\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0432 \u044d\u0442\u043e\u043c \u0436\u0435 \u043e\u043a\u043d\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 <a href=\"https:\/\/www.flickr.com\/services\/apps\/72157650173683580\/auth\">Edit auth flow for this app<\/a>. <\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/a86\/160\/4b5\/a861604b5dd0473bb9bcad1d69cd5ac9.jpg\"\/><\/p>\n<p>  \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438 \u043b\u043e\u0433\u043e\u0442\u0438\u043f \u043d\u0430\u043c \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b, \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e. \u0412 \u043f\u043e\u043b\u0435 Callback URL \u043d\u0430\u043c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043d\u0430\u0448\u0435\u043c\u0443 Activity. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0437\u0430\u0434\u0430\u044e <b>appforflickr:\/\/callback<\/b>. \u0412 \u0431\u043e\u043b\u043a\u0435 <i>&lt;intent-filter&gt;<\/i> \u044d\u0442\u043e \u0431\u0443\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"xml\">... &lt;data android:scheme=&quot;appforflickr&quot; android:host=&quot;callback&quot;\/&gt; ... <\/code><\/pre>\n<p>App Type \u2014 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c Web Application \u0438 \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0412 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <i>\u00abandroid.permission.INTERNET\u00bb<\/i> \u0438 \u0431\u043b\u043e\u043a <i>&lt;intent-filter&gt;<\/i> \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;manifest xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;     package=&quot;test.testflickrapi&quot; &gt;      &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;\/&gt;      &lt;application         android:allowBackup=&quot;true&quot;         android:icon=&quot;@drawable\/ic_launcher&quot;         android:label=&quot;@string\/app_name&quot;         android:theme=&quot;@style\/AppTheme&quot; &gt;         &lt;activity             android:name=&quot;.ui.activities.MainActivity&quot;             android:label=&quot;@string\/app_name&quot; &gt;             &lt;intent-filter&gt;                 &lt;action android:name=&quot;android.intent.action.MAIN&quot; \/&gt;                  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; \/&gt;             &lt;\/intent-filter&gt;             &lt;intent-filter&gt;                 &lt;action android:name=&quot;android.intent.action.VIEW&quot;\/&gt;                  &lt;category android:name=&quot;android.intent.category.DEFAULT&quot;\/&gt;                 &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot;\/&gt;                  &lt;data android:scheme=&quot;appforflickr&quot; android:host=&quot;callback&quot;\/&gt;             &lt;\/intent-filter&gt;         &lt;\/activity&gt;     &lt;\/application&gt;  &lt;\/manifest&gt; <\/code><\/pre>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/h4>\n<p>  \u0414\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c Activity \u0441 WebView. \u041d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0430\u0434\u0440\u0435\u0441 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430. \u0428\u0430\u0431\u043b\u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"html\">http:\/\/flickr.com\/services\/auth\/?api_key=[api_key]&perms=[perms]&api_sig=[api_sig] <\/code><\/pre>\n<p>[api_key] \u2014 \u044d\u0442\u043e \u043d\u0430\u0448 \u043a\u043b\u044e\u0447 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b\u0439 \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. [perms] \u2014 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0443, \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:  <\/p>\n<ul>\n<li>read \u2014 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u044f \u043b\u0438\u0447\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/li>\n<li>write \u2014 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438(\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f &#8216;read&#8217;)<\/li>\n<li>delete \u2014 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439(\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f &#8216;read&#8217; \u0438 &#8216;write &#8216;)<\/li>\n<\/ul>\n<p>  [api_sig] \u2014 \u043f\u043e\u0434\u043f\u0438\u0441\u044c, \u043e\u043d\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f <i>Secret<\/i> \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b\u0439 \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0438\u043c\u044f \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. <br \/>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 API Key: <i>5744fadec815a7e8142d03901065c97b<\/i>, API Secret: <i>8b2c12e80b67970b<\/i>, \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 <i>write<\/i>, \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u044d\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u0437: <\/p>\n<pre><code class=\"html\">secret + 'api_key' + [api_key] + 'perms' + [perms] <\/code><\/pre>\n<p>, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u0438\u043c\u0435\u0435\u043c: <i>8b2c12e80b67970bapi_key5744fadec815a7e8142d03901065c97bpermswrite<\/i> \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 MD5. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434: <\/p>\n<pre><code class=\"java\">public static final String md5SumOfString(final String s) {         try {             MessageDigest digest = java.security.MessageDigest.getInstance(&quot;MD5&quot;);             digest.update(s.getBytes());             byte messageDigest[] = digest.digest();              StringBuffer hexString = new StringBuffer();             for (int i = 0; i &lt; messageDigest.length; i++)                 hexString.append(Integer.toHexString(0xFF & messageDigest[i]));             return hexString.toString();          } catch (NoSuchAlgorithmException e) {             e.printStackTrace();         }         return &quot;&quot;;     } <\/code><\/pre>\n<p>  \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f [api_sig].<\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u0430\u0434\u0440\u0435\u0441 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"html\">http:\/\/www.flickr.com\/services\/auth\/?api_key=9a0554259914a86fb9e7eb014e4e5d52&perms=write&api_sig=b8d7c1ae026d5f86f1f44944f5257f3 <\/code><\/pre>\n<p>\u0412 onCreate() \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <\/p>\n<pre><code class=\"java\">startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); <\/code><\/pre>\n<p>, \u0433\u0434\u0435 url \u2014 \u044d\u0442\u043e \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u044b \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c. \u0415\u0441\u043b\u0438 \u0432\u0432\u0435\u0434\u0435\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u0435\u0440\u043d\u044b \u043d\u0430\u0441 \u043f\u043e <i>Callback URL<\/i> \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442 \u043d\u0430 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u044f. \u041a url \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <i>frob<\/i> \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c, \u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"html\">appforflickr:\/\/callback?frob=72157650137623777-b09eae52121bf8ad-130818926 <\/code><\/pre>\n<p><i>Frob<\/i> \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f <i>Access token<\/i>.<br \/>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432 onCreate(), \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <i>frob:<\/i><\/p>\n<pre><code class=\"java\">Uri uri = getIntent().getData(); if (uri != null) {     String frob = uri.getQueryParameter(&quot;frob&quot;); } else  \tstartActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/www.flickr.com\/services\/api\/flickr.auth.getToken.html\">flickr.auth.getToken<\/a> \u0438\u0437 <a href=\"https:\/\/www.flickr.com\/services\/api\/\">API<\/a> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f <i>token<\/i> \u0438 <i>nsid<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0430 \u0442\u0430\u043a \u0436\u0435 <i>username<\/i> \u0438 <i>fullname<\/i> \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>  \u0414\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c class HttpRequest:<\/p>\n<pre><code class=\"java\">public class HttpRequest extends AsyncTask&lt;String, String, String&gt; {      public static final String TAG = HttpRequest.class.getSimpleName();      @Override     protected void onPreExecute() {         Log.d(TAG, &quot;START&quot;);     }      @Override     protected String doInBackground(String... params) {         String result = &quot;&quot;;         try {             String uri = params[0];             HttpGet httpGet = new HttpGet(uri);             HttpResponse response = HttpClientHelper.getHttpClient().execute(httpGet);             HttpEntity entity = response.getEntity();             if (entity != null) {                 InputStream inStream = entity.getContent();                 result = InputStreamConverter.convertStreamToString(inStream);                 inStream.close();             }             return result;         } catch (IllegalStateException e) {             return result;         } catch (ClientProtocolException e) {             return result;         } catch (IOException e) {             return result;         }     }      @Override     protected void onPostExecute(String result) {         Log.d(TAG, &quot;STOP&quot;);     } } <\/code><\/pre>\n<p>  Class HttpClientHelper \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f HttpClient:<\/p>\n<pre><code class=\"java\">public class HttpClientHelper {      private static HttpClient httpClient = null;     private static final int REGISTRATION_TIMEOUT = 30 * 1000;     private static final int WAIT_TIMEOUT = 30 * 1000;      private HttpClientHelper() {}      public static synchronized HttpClient getHttpClient() {         if (httpClient == null) {             HttpParams params = new BasicHttpParams();             HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);             HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);             HttpProtocolParams.setUseExpectContinue(params, true);             ConnManagerParams.setTimeout(params, WAIT_TIMEOUT);             HttpConnectionParams.setConnectionTimeout(params, REGISTRATION_TIMEOUT);             HttpConnectionParams.setSoTimeout(params, WAIT_TIMEOUT);             SchemeRegistry schemeReg = new SchemeRegistry();             schemeReg.register(new Scheme(&quot;http&quot;, PlainSocketFactory.getSocketFactory(), 80));             schemeReg.register(new Scheme(&quot;https&quot;, SSLSocketFactory.getSocketFactory(), 443));             ClientConnectionManager connectionMgr = new ThreadSafeClientConnManager(params, schemeReg);             httpClient = new DefaultHttpClient(connectionMgr, params);         }         return httpClient;     } } <\/code><\/pre>\n<p>  Class InputStreamConverter \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 InputStream \u0432 String:<\/p>\n<pre><code class=\"java\">public class InputStreamConverter {      private InputStreamConverter() {}      public static String convertStreamToString(InputStream inputStream) {         BufferedReader reader = new BufferedReader(new InputStreamReader( inputStream));         StringBuilder builder = new StringBuilder();         String line = null;         try {             while ((line = reader.readLine()) != null) {                 builder.append(line + &quot;\\n&quot;);             }         } catch (IOException e) {             e.printStackTrace();         } finally {             try {                 inputStream.close();             } catch (IOException e) {                 e.printStackTrace();             }         }         return builder.toString();     } } <\/code><\/pre>\n<p>  \u0410\u0434\u0440\u0435\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f token: <\/p>\n<pre><code class=\"html\">https:\/\/api.flickr.com\/services\/rest\/?method=flickr.auth.getToken&api_key=9a0554259914a86fb9e7eb014e4e5d52&frob=72157650137623777-b09eae52121bf8ad-130818926&format=json&nojsoncallback=1&perms=write&api_sig=8fd09b55f670ec9a4ba07c076e520ae8 <\/code><\/pre>\n<p>, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0448\u0435\u043b \u0432 \u0432\u0438\u0434\u0435 json \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043f\u0435\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 <i>format=json<\/i> \u0438 <i>nojsoncallback=1<\/i><\/p>\n<p>  \u0412\u043d\u043e\u0441\u0438\u043c \u0435\u0449\u0435 \u0440\u0430\u0437 \u0438\u0437\u043c\u0438\u043d\u0435\u043d\u0438\u044f \u0432 onCreate() \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"java\">Uri uri = getIntent().getData(); if (uri != null) {     String frob = uri.getQueryParameter(&quot;frob&quot;);     String url = &quot;...&quot;; \/\/ \u041d\u0430\u0448 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f token \t \tString response = &quot;&quot;; \tHttpRequest httpRequest = new HttpRequest(this); \thttpRequest.execute(url); \ttry { \t\tresponse = httpRequest.get(); \t} catch (InterruptedException | ExecutionException e) { \t\te.printStackTrace(); \t} \t } else  \tstartActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442:<\/p>\n<pre><code class=\"xml\">{&quot;auth&quot;:{&quot;token&quot;:{&quot;_content&quot;:&quot;12134650097774510-014feda8303a4a64&quot;},&quot;perms&quot;:{&quot;_content&quot;:&quot;write&quot;},&quot;user&quot;:{&quot;nsid&quot;:&quot;230211065@N05&quot;,&quot;username&quot;:&quot;user&quot;,&quot;fullname&quot;:&quot;User Alex&quot;}},&quot;stat&quot;:&quot;ok&quot;} <\/code><\/pre>\n<p>\u043c\u043e\u0436\u043d\u0430 \u0440\u043e\u0437\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0436\u0435\u043b\u0430\u043d\u043d\u044b\u0439 <b>token<\/b> \u0438 <b>nsid<\/b> \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0442\u0430\u043a\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043a\u0430\u043a <a href=\"https:\/\/code.google.com\/p\/google-gson\/\">gson<\/a> \u0438\u043b\u0438 <a href=\"http:\/\/jackson.codehaus.org\/\">jackson<\/a> \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0430 \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u044f.<\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u043e\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u0443-\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0430.<\/p>\n<p>  PS. \u042d\u0442\u043e \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0441\u0442 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435, \u0442\u0430\u043a \u0447\u0442\u043e \u0438\u0437\u0432\u0438\u043d\u0438\u0442\u0435 \u0437\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0432\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/249961\/\"> http:\/\/habrahabr.ru\/post\/249961\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440\u0430\u043b\u044e\u0434\u0438!<\/p>\n<p>  \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Flickr API \u0432 Android \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Flickr. \u041a\u043e\u0442\u043e\u0440\u0443\u044e \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432 \u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-249961","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/249961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=249961"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/249961\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=249961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=249961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=249961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}