{"id":259928,"date":"2015-06-23T13:08:02","date_gmt":"2015-06-23T09:08:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=259928"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=259928","title":{"rendered":"\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 API \u0432 PHP"},"content":{"rendered":"<p>     \t\u042e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0435\u043e\u0442\u044a\u0435\u043c\u043b\u0435\u043c\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0438 \u043e\u043d\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0438 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0432\u0435\u0435, \u0435\u0441\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0412\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u2014 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u043c API \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b. \u041d\u0435\u043c\u0430\u043b\u043e \u043a\u043e\u043f\u0438\u0439 \u0441\u043b\u043e\u043c\u0430\u043d\u043e \u043e \u0442\u0435\u043c\u0443, \u043a\u0430\u043a\u0438\u043c \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u0445, \u0438 \u0433\u0434\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0433\u0440\u0430\u043d\u044c \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u0447\u0443\u0436\u0438\u0445 API. <\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u0430 \u043a\u0430\u043a\u0438\u0435 \u0441\u0438\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u043c\u0430\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043a\u0430\u043a \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0438\u0445 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438. \u0412 \u0441\u0432\u043e\u0451\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0442\u043e, \u0438 \u0434\u0440\u0443\u0433\u043e\u0435 \u043d\u0430 \u0431\u0430\u0437\u0435 HTTP \u043a\u043b\u0438\u0435\u043d\u0442\u0430 Guzzle.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/8b2\/d17\/0e4\/8b2d170e4de74b9d91d7fa160656b8ad.jpg\"\/><br \/>  <a name=\"habracut\"><\/a> <\/p>\n<p>  \u041f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435. <a href=\"http:\/\/guzzlephp.org\/\">Guzzle<\/a> \u2014 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 HTTP \u043a\u043b\u0438\u0435\u043d\u0442 \u0434\u043b\u044f PHP. \u041e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. \u0417\u0430 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0439 \u0433\u043e\u0434 \u0434\u0432\u0435 \u0441\u0442\u0430\u0440\u0448\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0438. \u0412\u0435\u0440\u0441\u0438\u044f 4.0.0 \u0432\u044b\u0448\u043b\u0430 \u0432 \u043c\u0430\u0440\u0442\u0435 2014, \u0430 \u043c\u0430\u0439 2015 \u043f\u0440\u0438\u043d\u0451\u0441 \u0440\u0435\u043b\u0438\u0437 \u0432\u0435\u0440\u0441\u0438\u0438 6.0.0. \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u0442.\u043a. \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u043b\u0438\u0437\u0435 \u043c\u0435\u043d\u044f\u044e\u0442 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b. <\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0432\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432, \u0434\u0430\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e. \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u0435\u043d\u044c\u043a\u043e \u043f\u043e\u0433\u0443\u0433\u043b\u0438\u0442\u044c \u0438 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u043e\u0434\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0432 \u0438\u0442\u043e\u0433\u0435 \u0443\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h4>\n<p>  Guzzle \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/getcomposer.org\/\">Composer<\/a>. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b composer.json \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u043d\u0443\u0436\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">{     &quot;name&quot;: &quot;our-guzzle-test&quot;,     &quot;description&quot;: &quot;Guzzle setup API testing&quot;,     &quot;minimum-stability&quot;: &quot;dev&quot;,     &quot;require&quot;: {         &quot;guzzlehttp\/guzzle&quot;: &quot;5.*&quot;,         &quot;guzzlehttp\/log-subscriber&quot;: &quot;*&quot;,         &quot;monolog\/monolog&quot;: &quot;*&quot;,         &quot;guzzlehttp\/oauth-subscriber&quot;: &quot;*&quot;     } } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0448\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 3-\u0448\u0430\u0433\u043e\u0432\u0443\u044e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e OAuth, \u043f\u043e\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 Guzzle 5.3. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0430\u044f \u043f\u043b\u0430\u0433\u0438\u043d oauth-subsctiber. \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u0412\u0430\u043c OAuth \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0438 6.*. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0432\u0435\u0440\u044c\u0442\u0435\u0441\u044c \u0441 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439.<\/p>\n<h4>\u041f\u0435\u0440\u0432\u044b\u0435 \u0448\u0430\u0433\u0438<\/h4>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0412\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0430\u0432\u0442\u043e\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 Composer:<\/p>\n<pre><code class=\"php\">require_once &quot;path_to_composer_files\/vendor\/autoload.php&quot;; <\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448\u0438\u043c\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0437\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438\u0445.<\/p>\n<p>  <b>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"php\">\/\/ \u0421\u0430\u043c \u043a\u043b\u0438\u0435\u043d\u0442 use GuzzleHttp\\Client;  \/\/ \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u0435 OAuth   use GuzzleHttp\\Subscriber\\Oauth\\Oauth1;    \/\/ \u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 use GuzzleHttp\\Subscriber\\Log\\LogSubscriber;   use Monolog\\Logger;   use Monolog\\Handler\\StreamHandler;   use GuzzleHttp\\Subscriber\\Log\\Formatter; <\/code><\/pre>\n<p>  <b>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u0441\u0438\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"php\">use GuzzleHttp\\Subscriber\\Mock;   use GuzzleHttp\\Message\\Response;   use GuzzleHttp\\Stream\\Stream;  <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/h4>\n<p>  \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0443 \u043d\u0430\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:  <\/p>\n<ul>\n<li><b><i>$isUnitTest<\/i><\/b> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432 \u0448\u0442\u0430\u0442\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0438\u043b\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f; <\/li>\n<li><b><i>$recordTestResults<\/i><\/b> \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432. <\/li>\n<\/ul>\n<p>  <\/p>\n<h5>\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b OAuth<\/h5>\n<p>  Guzzle \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u043a\u0430\u043a \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 OAuth (\u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u0441\u0445\u0435\u043c\u0430\u043c), \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<pre><code class=\"php\">    $oauthKeys = [         'consumer_key'    =&gt; OAUTH_CONSUMER_KEY,         'consumer_secret' =&gt; OAUTH_CONSUMER_SECRET,     ];     if ($authStatus == 'preauth') { \/\/ \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0430\u044f \u0447\u0430\u0441\u0442\u044c 3-\u044d\u0442\u0430\u043f\u043d\u043e\u0439 OAuth \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438         $oauthKeys['token']        = $oauth_request_token;         $oauthKeys['token_secret'] = $oauth_request_token_secret;     } elseif ($authStatus == 'auth') { \/\/ \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441         $oauthKeys['token']        = $oauth_access_token;         $oauthKeys['token_secret'] = $oauth_access_token_secret;     }     $oauth = new Oauth1($oauthKeys); <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b <b><i>OAUTH_CONSUMER_KEY<\/i><\/b> \u0438 <b><i>OAUTH_CONSUMER_SECRET<\/i><\/b> \u2014 \u043f\u0430\u0440\u0430 \u043a\u043b\u044e\u0447\u0435\u0439, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0412\u0430\u0448\u0438\u043c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u043c API. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043a\u0435\u043d \u0438 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u043a \u043d\u0435\u043c\u0443. \u0417\u0430 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e\u0431 OAuth \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"http:\/\/oauthbible.com\/\">OAuth Bible<\/a>).<\/p>\n<h5>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f HTTP-\u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/h5>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0448\u0430\u0433\u0435 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u043d\u0430\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<pre><code class=\"php\">    if (empty($isUnitTest) || !empty($recordTestResults)) {         $client = new Client(['base_url' =&gt; $apiUrl, 'defaults' =&gt; ['auth' =&gt; 'oauth']]);         $client-&gt;getEmitter()-&gt;attach($oauth);     } else {         $mock   = getResponseLocally($requestUrl, $requestBody);         $client = new Client();         $client-&gt;getEmitter()-&gt;attach($mock);     } <\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><b><i>$apiUrl<\/i><\/b> \u2014 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0443\u0442\u044c \u0412\u0430\u0448\u0435\u0433\u043e API<\/li>\n<li><b><i>&#8216;defaults&#8217; =&gt; [&#8216;auth&#8217; =&gt; &#8216;oauth&#8217;]<\/i><\/b> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0412\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b OAuth. \u0422\u043e \u0436\u0435 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e \u0438 \u0434\u043b\u044f <i>$client-&gt;getEmitter()-&gt;attach($oauth);<\/i><\/li>\n<li><b><i>$requestUrl<\/i><\/b> \u2014 \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0443\u0442\u044c)<\/li>\n<li><b><i>$requestBody<\/i><\/b> \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c)<\/li>\n<\/ul>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>getResponseLocally()<\/i> \u044f \u043e\u043f\u0438\u0448\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437\u0436\u0435. \u0415\u0441\u043b\u0438 \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <i>$inDevMode<\/i> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"php\">    if ($inDevMode) {          $log = new Logger('guzzle');         $log-&gt;pushHandler(new StreamHandler('\/tmp\/guzzle.log'));         $subscriber = new LogSubscriber($log, Formatter::SHORT);         $client-&gt;getEmitter()-&gt;attach($subscriber);     } <\/code><\/pre>\n<p>  <\/p>\n<h5>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u043e\u0432<\/h5>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u042f \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u043a\u043e\u0434 HTTP-\u043e\u0442\u0432\u0435\u0442\u0430. \u0415\u0441\u043b\u0438 \u043e\u043d \u0412\u0430\u043c \u043d\u0443\u0436\u0435\u043d, \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434.<\/p>\n<pre><code class=\"php\">    $request = $client-&gt;createRequest($method, $requestUrl, ['headers' =&gt; $requestHeaders, 'body' =&gt; $requestBody, 'verify' =&gt; false]);     $output  = new stdClass();     try {         $response       = $client-&gt;send($request, ['timeout' =&gt; 2]);         $responseRaw    = (string)$response-&gt;getBody();         $headers        = $response-&gt;getHeaders();     } catch (Exception $e) {         $responseRaw    = $e-&gt;getResponse();         $headers        = array();     }     if ($recordTestResults) {         saveResponseLocally($requestUrl, $requestBody, $headers, $responseRaw);     } <\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><b><i>$method<\/i><\/b> \u2014 HTTP request method (GET, POST, PUT etc)<\/li>\n<li><b><i>$requestHeaders<\/i><\/b> \u2014 request headers (if needed)<\/li>\n<li><b><i>$headers<\/i><\/b> \u2014 response headers<\/li>\n<li><b><i>$responseRaw<\/i><\/b> \u2014 raw response (you may get XML, JSON or whatever else as a response but you need to save it before decoding)<\/li>\n<\/ul>\n<p>  <\/p>\n<h4>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432<\/h4>\n<p>  \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043f\u0438\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u044b \u0438\u043b\u0438 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0430\u043a\u043e\u0439 \u0431\u044b \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0412\u044b \u043d\u0438 \u0432\u044b\u0431\u0440\u0430\u043b\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u0430\u043a\u0438\u043c-\u043b\u0438\u0431\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u043e\u0442\u0432\u0435\u0442\u043e\u043c. \u042f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 MD5-\u0445\u0435\u0448\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 <b><i>$requestUrl<\/i><\/b> \u0438 <b><i>$requestBody<\/i><\/b>. \u041c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u043f\u0430\u0440\u043a\u0443\u0435\u0442\u0441\u044f \u0432 JSON \u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043b\u043e\u043c \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a php-\u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <i>require()<\/i>.<\/p>\n<pre><code class=\"php\">function saveResponseLocally ($requestUrl, $requestBody, $headers_source, $response) {       if (!is_string($requestBody)) {          $requestBody = print_r($requestBody, true);     }     $filename = md5($requestUrl) . md5($requestBody);     $headers  = array();     foreach ($headers_source as $name =&gt; $value) {         if (is_array($value)) {             $headers[$name] = $value[0]; \/\/ Guzzle returns some header values as 1-element array         } else {             $headers[$name] = $value;         }     }     $response     = htmlspecialchars($response, ENT_QUOTES);     $headers_json = json_encode($headers);     $data         = &quot;&lt;?\\n\\$data = array('headers_json' =&gt; '$headers_json', \\n'response' =&gt; '$response');&quot;;     $requestData  = &quot;&lt;?\\n\\$reqdata = array('url' =&gt; '$requestUrl', \\n'body' =&gt; '$requestBody');&quot;;     file_put_contents(&quot;path_of_your_choice\/localResponses\/{$filename}.inc&quot;, $data);     file_put_contents(&quot;path_of_your_choice\/localResponses\/{$filename}_req.inc&quot;, $requestData); } <\/code><\/pre>\n<p>  \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0412\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c <b><i>$requestData<\/i><\/b>. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0434\u0430\u043d\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430.<\/p>\n<p>  \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b, \u044f \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u043a\u043e\u0434 \u043e\u0442\u0432\u0435\u0442\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u044e \u0432\u0441\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0441 \u043a\u043e\u0434\u043e\u043c 200. \u0415\u0441\u043b\u0438 \u0412\u0430\u0448\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e HTTP \u043a\u043e\u0434\u0430, \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c.  <\/p>\n<pre><code class=\"php\">function getResponseLocally ($requestUrl, $requestBody) {       if (!is_string($requestBody)) {         $requestBody = print_r($requestBody, true);     }     $filename = md5($requestUrl) . md5($requestBody) . '.inc';     if (file_exists(&quot;path_of_your_choice\/localResponses\/{$filename}&quot;)) {         require(&quot;path_of_your_choice\/localResponses\/{$filename}&quot;);         $data['headers'] = (array)json_decode($data['headers_json']);         $mockResponse    = new Response(200);         $mockResponse-&gt;setHeaders($data['headers']);         $separator = &quot;\\r\\n\\r\\n&quot;;         $bodyParts = explode($separator, htmlspecialchars_decode($data['response']), ENT_QUOTES);         if (count($bodyParts) &gt; 1) {             $mockResponse-&gt;setBody(Stream::factory($bodyParts[count($bodyParts) - 1]));         } else {             $mockResponse-&gt;setBody(Stream::factory(htmlspecialchars_decode($data['response'])));         }         $mock = new Mock([             $mockResponse         ]);         return $mock;     } else {         return false;     } } <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0418 \u0432 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435&#8230;<\/h4>\n<p>  \u042f \u043e\u043f\u0438\u0441\u0430\u043b \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 API \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u0438 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 (\u0432 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0442\u0432\u0435\u0442\u0430\u043c\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 10-20 \u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0435\u043c \u00ab\u0431\u043e\u0435\u0432\u044b\u0435\u00bb \u0437\u0430\u043f\u0440\u043e\u0441\u044b). Guzzle \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0449\u0451 <a href=\"http:\/\/guzzle.readthedocs.org\/en\/v5\/testing.html\">\u043f\u0430\u0440\u0443 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/a> \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0412\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0412\u044b \u0434\u0430\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440 API, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0412\u0430\u043c \u043e\u0442\u0432\u0435\u0442\u044b. \u041a\u0430\u043a\u043e\u0439 \u0431\u044b \u043f\u0443\u0442\u044c \u0412\u044b \u043d\u0438 \u0432\u044b\u0431\u0440\u0430\u043b\u0438, \u0412\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u043d\u0435\u043c\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0438\u0437\u0431\u0435\u0436\u0438\u0442\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0412\u0430\u0448\u0438\u043c API \u043f\u0430\u0440\u0442\u043d\u0451\u0440\u0430\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/855\/bec\/74f\/855bec74f5de43ed99d475931be9e5f3.jpg\"\/>     \t<\/p>\n<div class=\"clear\"><\/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\/260221\/\"> http:\/\/habrahabr.ru\/post\/260221\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u042e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0435\u043e\u0442\u044a\u0435\u043c\u043b\u0435\u043c\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0438 \u043e\u043d\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0438 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0432\u0435\u0435, \u0435\u0441\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0412\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u2014 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u043c API \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b. \u041d\u0435\u043c\u0430\u043b\u043e \u043a\u043e\u043f\u0438\u0439 \u0441\u043b\u043e\u043c\u0430\u043d\u043e \u043e \u0442\u0435\u043c\u0443, \u043a\u0430\u043a\u0438\u043c \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u0445, \u0438 \u0433\u0434\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0433\u0440\u0430\u043d\u044c \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u0447\u0443\u0436\u0438\u0445 API. <\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u0430 \u043a\u0430\u043a\u0438\u0435 \u0441\u0438\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u043c\u0430\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043a\u0430\u043a \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0438\u0445 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438. \u0412 \u0441\u0432\u043e\u0451\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0442\u043e, \u0438 \u0434\u0440\u0443\u0433\u043e\u0435 \u043d\u0430 \u0431\u0430\u0437\u0435 HTTP \u043a\u043b\u0438\u0435\u043d\u0442\u0430 Guzzle.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/8b2\/d17\/0e4\/8b2d170e4de74b9d91d7fa160656b8ad.jpg\"\/>  <\/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-259928","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/259928","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=259928"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/259928\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=259928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=259928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=259928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}