{"id":302444,"date":"2020-04-24T15:00:15","date_gmt":"2020-04-24T15:00:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=302444"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=302444","title":{"rendered":"Cloudflare PHP API Binding"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/498936\/\"><b><i>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/QCBO\/\">\u00abBackend-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 PHP\u00bb<\/a>.<\/i><\/b><\/p>\n<hr>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 PHP 7.0 \u0438\u043b\u0438 \u0432\u044b\u0448\u0435, Cloudflare \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 PHP API \u0431\u0438\u043d\u0434\u0438\u043d\u0433. \u041e\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e API Cloudflare. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 SDK \u0434\u043b\u044f \u0440\u044f\u0434\u0430 \u0446\u0435\u043b\u0435\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a:<\/p>\n<ul>\n<li>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0441\u0432\u043e\u0438\u0445 DNS-\u0437\u0430\u043f\u0438\u0441\u044f\u0445 \u0432 Cloudflare.<\/li>\n<li>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u043e\u043d \u0432 \u0441\u0432\u043e\u044e \u0443\u0447\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c.<\/li>\n<li>\u0412\u0435\u0440\u0441\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 Page Rules<\/li>\n<li>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 IP-\u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0438 User Agent-\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Zone Lockdown \u0438 UserAgent Rules.<\/li>\n<li>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 IP-\u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432 Cloudflare \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0430\u0439\u0442\u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u043e\u043c<\/li>\n<\/ul>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h3>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f PHP API \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430 Cloudflare; \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438:<\/p>\n<p>  <u>V4 \u042d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u044b<\/u><\/p>\n<ul>\n<li>DNS<\/li>\n<li>IPs<\/li>\n<li>Page Rules<\/li>\n<li>User Agent Rules<\/li>\n<li>User Management (\u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0435)<\/li>\n<li>Zone Lockdown<\/li>\n<li>Zones<\/li>\n<\/ul>\n<p>  <u>\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/u><\/p>\n<ul>\n<li>User Service Keys<\/li>\n<li>API Keys<\/li>\n<\/ul>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h3>\n<p>  <a href=\"https:\/\/packagist.org\/packages\/cloudflare\/sdk\">Cloudflare PHP API \u0431\u0438\u043d\u0434\u0438\u043d\u0433<\/a> \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 Packagist \u0432 <a href=\"https:\/\/packagist.org\/packages\/cloudflare\/sdk\">cloudflare\/sdk<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Composer \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u0430 <i>composer require cloudflare\/sdk<\/i>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ra\/gn\/s-\/ragns-qb86azljrwkxq26doour4.png\"><\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0438\u043b\u0438 \u0432\u043d\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u0439 \u0432\u043a\u043b\u0430\u0434 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 GitHub \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/cloudflare\/cloudflare-php\">cloudflare\/cloudflare-php<\/a>. <\/p>\n<h3>\u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b<\/h3>\n<p>  \u0412\u043e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 API<br \/>  &lt;?php<\/p>\n<pre><code class=\"php\">require_once('vendor\/autoload.php');  $key = new \\Cloudflare\\API\\Auth\\APIKey('mjsa@junade.com', 'API KEY GOES HERE'); $adapter = new Cloudflare\\API\\Adapter\\Guzzle($key); $user = new \\Cloudflare\\API\\Endpoints\\User($adapter);  echo 'Your user ID is: ' . $user-&gt;getUserID() . PHP_EOL;<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ew\/cu\/bp\/ewcubpbmeafkantvubksfjqq0h0.png\"><\/p>\n<h3>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 \u0437\u043e\u043d<\/h3>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u0437\u043e\u043d\u044b \u0432 \u0443\u0447\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"php\">&lt;?php  require_once('vendor\/autoload.php');  $key = new \\Cloudflare\\API\\Auth\\APIKey('mjsa@junade.com', 'API KEY GOES HERE'); $adapter = new Cloudflare\\API\\Adapter\\Guzzle($key);  $zones = new \\Cloudflare\\API\\Endpoints\\Zones($adapter); foreach ($zones-&gt;listZones()-&gt;result as $zone) {    echo $zone-&gt;name.' ('.$zone-&gt;plan-&gt;name.')'.PHP_EOL; }<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u0430\u0441\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rj\/jh\/h7\/rjjhh75lnocyi_bh1zliqzl0gjq.png\"><\/p>\n<h3>\u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u043a\u044d\u0448\u0430 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0430\u0445<\/h3>\n<p>  \u0412\u043e\u0442 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 Purge Cache \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u043a\u044d\u0448\u0430 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0435 \u043d\u0430\u0448\u0435\u0439 \u0443\u0447\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 (\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u043a\u044d\u0448, \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0432 \u043c\u0435\u0442\u043e\u0434 cachePurge \u0432\u043c\u0435\u0441\u0442\u043e cachePurgeEverything):<\/p>\n<pre><code class=\"php\">&lt;?php  require_once('vendor\/autoload.php');  $key = new \\Cloudflare\\API\\Auth\\APIKey('mjsa@junade.com', 'API KEY GOES HERE'); $adapter = new Cloudflare\\API\\Adapter\\Guzzle($key);  $zones = new \\Cloudflare\\API\\Endpoints\\Zones($adapter); foreach ($zones-&gt;listZones()-&gt;result as $zone) {    echo &quot;Cache purge for &quot; . $zone-&gt;name . &quot;: &quot;;    echo $zones-&gt;cachePurgeEverything($zone-&gt;id) == true ? &quot;successful&quot; : &quot;failed&quot;;    echo PHP_EOL;  }<\/code><\/pre>\n<p>  \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ma\/td\/dp\/matddprqolf2ppse1nhcx1i8fek.png\"><\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Page Rules<\/h3>\n<p>  SDK \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f Page Rules \u0432 Cloudflare Zone. \u0412\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430 Cache Bypass:<\/p>\n<pre><code class=\"php\">&lt;?php  require_once('vendor\/autoload.php');  $key = new \\Cloudflare\\API\\Auth\\APIKey('mjsa@junade.com', 'API KEY GOES HERE'); $adapter = new Cloudflare\\API\\Adapter\\Guzzle($key); $zones = new \\Cloudflare\\API\\Endpoints\\Zones($adapter);  $zoneID = $zones-&gt;getZoneID(&quot;junade.com&quot;);  $pageRulesTarget = new \\Cloudflare\\API\\Configurations\\PageRulesTargets('https:\/\/junade.com\/noCache\/*');  $pageRulesConfig = new \\Cloudflare\\API\\Configurations\\PageRulesActions(); $pageRulesConfig-&gt;setCacheLevel('bypass');  $pageRules = new \\Cloudflare\\API\\Endpoints\\PageRules($adapter); $pageRules-&gt;createPageRule($zoneID, $pageRulesTarget, $pageRulesConfig, true, 6);<\/code><\/pre>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c ID \u043d\u0443\u0436\u043d\u043e\u0439 \u0437\u043e\u043d\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u0442\u043e\u0434 getZoneID \u043a\u043b\u0430\u0441\u0441\u0430 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0430 Zones \u2014 \u044d\u0442\u043e\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 ID \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0437\u043e\u043d\u044b.<br \/>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e SDK \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0446\u0435\u043b\u0438 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u0438\u043b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0412\u043e\u0442 \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 PageRulesTargets \u0438 PageRuleActions \u0432 \u043c\u0435\u0442\u043e\u0434 createPageRule.<\/p>\n<h3>DNS<\/h3>\n<p>  SDK \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f DNS-\u0437\u0430\u043f\u0438\u0441\u0438:<\/p>\n<pre><code class=\"php\">&lt;?php  require_once('vendor\/autoload.php');  $key = new \\Cloudflare\\API\\Auth\\APIKey('mjsa@junade.com', 'API KEY GOES HERE'); $adapter = new Cloudflare\\API\\Adapter\\Guzzle($key); $zones = new \\Cloudflare\\API\\Endpoints\\Zones($adapter);  $zoneID = $zones-&gt;getZoneID(&quot;junade.com&quot;);  $dns = new \\Cloudflare\\API\\Endpoints\\DNS($adapter); if ($dns-&gt;addRecord($zoneID, &quot;A&quot;, 'example', '8.8.8.8', 0, true) === true) {    echo &quot;DNS record created.&quot;. PHP_EOL; }<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0443\u0434\u0430\u043b\u044f\u0442\u044c, \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0438 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u0438 DNS-\u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e SDK. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u0438 \u0438\u043c\u0435\u043d\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 DNS-\u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0437\u043e\u043d\u0435:<\/p>\n<pre><code class=\"php\">&lt;?php  require_once('vendor\/autoload.php');  $key = new \\Cloudflare\\API\\Auth\\APIKey('mjsa@junade.com', 'API KEY GOES HERE'); $adapter = new Cloudflare\\API\\Adapter\\Guzzle($key); $zones = new \\Cloudflare\\API\\Endpoints\\Zones($adapter);  $zoneID = $zones-&gt;getZoneID(&quot;icyapril.com&quot;);  $dns = new \\Cloudflare\\API\\Endpoints\\DNS($adapter); foreach ($dns-&gt;listRecords($zoneID)-&gt;result as $record) {    echo $record-&gt;type.&quot; &quot;.$record-&gt;name.PHP_EOL; }<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u044f \u0437\u0430\u043f\u0443\u0449\u0443 \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043c\u043e\u0438\u0445 \u0437\u043e\u043d:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/zg\/x3\/k4\/zgx3k4solwu_3-mfk1x0dqzwqyq.png\"><\/p>\n<hr>\n<p>  <a href=\"https:\/\/otus.pw\/QCBO\/\">\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u0443\u0440\u0441\u0435<\/a><\/p>\n<hr>\n<\/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=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/498936\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/498936\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/498936\/\"><b><i>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/QCBO\/\">\u00abBackend-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 PHP\u00bb<\/a>.<\/i><\/b><\/p>\n<hr>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 PHP 7.0 \u0438\u043b\u0438 \u0432\u044b\u0448\u0435, Cloudflare \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 PHP API \u0431\u0438\u043d\u0434\u0438\u043d\u0433. \u041e\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e API Cloudflare. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 SDK \u0434\u043b\u044f \u0440\u044f\u0434\u0430 \u0446\u0435\u043b\u0435\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a:<\/p>\n<ul>\n<li>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0441\u0432\u043e\u0438\u0445 DNS-\u0437\u0430\u043f\u0438\u0441\u044f\u0445 \u0432 Cloudflare.<\/li>\n<li>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u043e\u043d \u0432 \u0441\u0432\u043e\u044e \u0443\u0447\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c.<\/li>\n<li>\u0412\u0435\u0440\u0441\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 Page Rules<\/li>\n<li>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 IP-\u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0438 User Agent-\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Zone Lockdown \u0438 UserAgent Rules.<\/li>\n<li>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 IP-\u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432 Cloudflare \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0430\u0439\u0442\u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 \u0444\u0430\u0439\u0440\u0432\u043e\u043b\u043e\u043c<\/li>\n<\/ul>\n<p>  <\/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-302444","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/302444","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=302444"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/302444\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=302444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=302444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=302444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}