{"id":366430,"date":"2024-05-21T02:59:20","date_gmt":"2024-05-21T02:59:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=366430"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T02:59:20","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=366430","title":{"rendered":"<span>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0430 \u042f\u043d\u0434\u0435\u043a\u0441 \u0441\u0432\u043e\u0438\u043c\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u0439\u0434\u0451\u0442 \u0440\u0435\u0447\u044c \u043e \u0441\u0430\u043c\u043e\u043c \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0430 \u042f\u043d\u0434\u0435\u043a\u0441 &#8212; \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\/\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0442.\u043a. \u043d\u0438\u0447\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u043d\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043d\u043e \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438. \u041c\u043e\u0436\u0435\u0442 \u044d\u0442\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043d\u0435 \u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044e \u0432\u043e\u0432\u0441\u0435, \u043d\u043e \u0432\u043e\u0442 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f. \u0417\u0430 \u043a\u043e\u0434 \u043d\u0435 \u0440\u0443\u0433\u0430\u0439\u0442\u0435 \u0441\u0438\u043b\u044c\u043d\u043e &#8212; \u044f \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442. \u041a\u043e\u0434 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c PHP.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c9e\/9a3\/b9c\/c9e9a3b9cd8ccefaf30e08c6d25f2a69.png\" alt=\"AI: \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0430 \u0441\u0432\u043e\u0438\u043c\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438 \u043d\u0430 PHP\" title=\"AI: \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0430 \u0441\u0432\u043e\u0438\u043c\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438 \u043d\u0430 PHP\" width=\"512\" height=\"512\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c9e\/9a3\/b9c\/c9e9a3b9cd8ccefaf30e08c6d25f2a69.png\"\/><\/p>\n<div><figcaption>AI: \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0430 \u0441\u0432\u043e\u0438\u043c\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438 \u043d\u0430 PHP<\/figcaption><\/div>\n<\/figure>\n<h2>\u0417\u0430\u0447\u0435\u043c?<\/h2>\n<p>\u0417\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043c\u043d\u0435 \u043a\u0430\u043a-\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0410\u043b\u0438\u0441\u0443. \u0410 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445? \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u044b. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0433\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043f\u0438\u043a\u043e\u0432\u044b\u0439 \u0442\u0430\u0440\u0438\u0444 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u044d\u043d\u0435\u0440\u0433\u0438\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0440\u0451\u0445\u0442\u0430\u0440\u0438\u0444\u043d\u043e\u0433\u043e \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u043f\u0438\u043a\u043e\u0432\u043e\u0433\u043e \u0442\u0430\u0440\u0438\u0444\u044b, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u044b\u043b \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0434\u043e \u044d\u0442\u043e\u0433\u043e.<\/p>\n<p>\u0414\u0430, \u0432 \u043c\u0438\u0440\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u0435\u0449\u0438 \u0442\u0438\u043f\u0430 Home Assistant, \u043d\u043e \u043f\u043e\u043a\u0430 \u043c\u043d\u0435 \u043b\u0435\u043d\u044c \u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u0434\u0430 \u0438 \u043a\u0430\u043a-\u0442\u043e \u043e\u0431\u0445\u043e\u0434\u0438\u043b\u0441\u044f \u0431\u0435\u0437 \u043d\u0435\u0433\u043e. \u041f\u043e\u043a\u0430 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u0435 \u043e\u0441\u043e\u0437\u043d\u0430\u043b, \u0437\u0430\u0447\u0435\u043c \u043e\u043d \u043c\u043d\u0435. \u0418 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0442\u0430\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u0412\u0430\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u0434\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0431\u044b\u043b \u0432\u043a\u043b\u044e\u0447\u0435\u043d. \u0415\u0441\u043b\u0438 \u0434\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u043f\u0438\u043a\u043e\u0432\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u0438\u0431\u043e\u0440 \u043d\u0435 \u0431\u044b\u043b \u0432\u043a\u043b\u044e\u0447\u0435\u043d, \u0442\u043e \u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0435 \u043d\u0430\u0434\u043e \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u043f\u0438\u043a\u043e\u0432\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<h2>\u041f\u043e\u0438\u0441\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/h2>\n<p>\u041d\u0430\u0447\u0430\u0442\u044c \u0440\u0435\u0448\u0438\u043b \u0441 API \u042f\u043d\u0434\u0435\u043a\u0441\u0430. \u0411\u043b\u0430\u0433\u043e \u0441 \u044d\u0442\u0438\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435\u0442, \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e:<\/p>\n<p><a href=\"https:\/\/yandex.ru\/dev\/dialogs\/smart-home\/doc\/concepts\/platform-quickstart.html\" rel=\"noopener noreferrer nofollow\">https:\/\/yandex.ru\/dev\/dialogs\/smart-home\/doc\/concepts\/platform-quickstart.html<\/a><\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043a\u0443\u0434\u043d\u0430 \u043d\u0430 \u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b. <\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u0435\u0435 \u0434\u0435\u043b\u043e &#8212; \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0441\u0432\u043e\u0451, \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0447\u0442\u043e-\u0442\u043e \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u043d\u0430 Github \u0438\u043b\u0438 \u0435\u0449\u0435 \u0433\u0434\u0435-\u0442\u043e. \u0427\u0435\u0441\u0442\u043d\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u044e\u0441\u044c, \u0438\u0441\u043a\u0430\u043b \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0433\u043b\u0443\u0431\u043e\u043a\u043e, \u043d\u043e \u043d\u0430\u0442\u044b\u043a\u0430\u043b\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u0439 &#171;\u0443\u043c\u043d\u044b\u0439 \u0434\u043e\u043c&#187; \u043a \u0410\u043b\u0438\u0441\u0435, \u0447\u0442\u043e \u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437 \u0410\u043b\u0438\u0441\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438.<\/p>\n<h2>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041a\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 oauth \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"https:\/\/oauth.yandex.ru\/client\/new\/\" rel=\"noopener noreferrer nofollow\">https:\/\/oauth.yandex.ru\/client\/new\/<\/a><\/p>\n<p>\u0412\u0430\u0436\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u0431\u0435\u0437\u0434\u0430\u0440\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432. \u041d\u0443\u0436\u043d\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u0430 \u043d\u0435 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043d\u0430\u0436\u0438\u043c\u0430\u0442\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 &#171;\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435&#187; &#8212; \u043e\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 &#171;id&#187;, \u0432 url \u0432\u0438\u0434\u043d\u043e \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 <a href=\"https:\/\/oauth.yandex.ru\/client\/new\/id\" rel=\"noopener noreferrer nofollow\">https:\/\/oauth.yandex.ru\/client\/new\/id<\/a> \u0438 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/859\/9a7\/471\/8599a74715d1ffbf3bc6e4cacf328936.png\" alt=\"\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f oauth Yandex\" title=\"\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f oauth Yandex\" width=\"1329\" height=\"1252\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/859\/9a7\/471\/8599a74715d1ffbf3bc6e4cacf328936.png\"\/><\/p>\n<div><figcaption>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f oauth Yandex<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043b\u044e\u0431\u043e\u0435.<\/p>\n<p>\u0413\u0430\u043b\u043e\u0447\u043a\u0430 &#8212; \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u044b.<\/p>\n<p>Redirect URI &#8212; \u0441\u0441\u044b\u043b\u043a\u0430, \u043a\u0443\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0430\u0434\u0440\u0435\u0441\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043d\u0430 \u043c\u043e\u0451\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/oauth.yandex.ru\/verification_code\" rel=\"noopener noreferrer nofollow\">http:\/\/oauth.yandex.ru\/verification_code<\/a> &#8212; \u044d\u0442\u043e\u0442 URL \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043a\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c &#8212; \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: <code>iot:view<\/code>,\u00a0<code>iot:control<\/code><\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043d\u0430\u0434\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0442\u043e\u043a\u0435\u043d \u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u0433\u043e\u0434, \u0437\u0430\u0442\u0435\u043c \u0435\u0433\u043e \u0432\u0440\u043e\u0434\u0435 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043b\u044f\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b, \u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0435\u0433\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f02\/dfc\/a0f\/f02dfca0fdc71ae78c1d28bbd6141053.png\" width=\"1734\" height=\"543\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f02\/dfc\/a0f\/f02dfca0fdc71ae78c1d28bbd6141053.png\"\/><\/figure>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 ClientID \u0438 Client secret &#8212; \u043e\u043d\u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f. \u041c\u043e\u0436\u043d\u043e \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c &#8212; \u043e\u043d\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h2>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430<\/h2>\n<p>\u0418\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a<\/p>\n<pre><code class=\"bash\">$ curl \"https:\/\/oauth.yandex.ru\/authorize?response_type=code&amp;client_id=&lt;client_id>&amp;force_confirm=no&amp;scope=iot:view%20iot:control\" Found. Redirecting to https:\/\/passport.yandex.ru\/auth?retpath=https%3A%2F%2Foauth.yandex.ru%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3D%253Cclient_id%253E%26force_confirm%3Dno%26scope%3Diot%3Aview%2520iot%3Acontrol&amp;noreturn=1&amp;origin=oauth<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0451\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u043e:<\/p>\n<p><a href=\"https:\/\/passport.yandex.ru\/auth?retpath=https%3A%2F%2Foauth.yandex.ru%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3D%253Cclient_id%253E%26force_confirm%3Dno%26scope%3Diot%3Aview%2520iot%3Acontrol&amp;noreturn=1&amp;origin=oauth\" rel=\"noopener noreferrer nofollow\">https:\/\/passport.yandex.ru\/auth?retpath=https%3A%2F%2Foauth.yandex.ru%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3D%253Cclient_id%253E%26force_confirm%3Dno%26scope%3Diot%3Aview%2520iot%3Acontrol&amp;noreturn=1&amp;origin=oauth<\/a><\/p>\n<p>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0443\u0435\u043c\u0441\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u0434 &#8212; \u043a\u043e\u0434 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 <a href=\"http:\/\/oauth.yandex.ru\/verification_code\" rel=\"noopener noreferrer nofollow\">http:\/\/oauth.yandex.ru\/verification_code<\/a> , \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0449\u0435 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432\u0430 \u0431\u043e\u043b\u0435\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441 \u044d\u0442\u0438\u043c \u043a\u043e\u0434\u043e\u043c, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0430\u043c \u0442\u043e\u043a\u0435\u043d:<\/p>\n<pre><code>curl -H \"Authorization: Basic $(echo -n \"&lt;ClientID>:&lt;Client secret>\"|base64 -w 0)\" -d \"grant_type=authorization_code&amp;code=&lt;code>\" \"https:\/\/oauth.yandex.ru\/token\"<\/code><\/pre>\n<p>\u0412 \u043e\u0442\u0432\u0435\u0442 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 JSON \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n<pre><code class=\"json\">{   \"token_type\": \"bearer\",   \"access_token\": \"AQAAAACy1C6ZAAAAfa6vDLuItEy8pg-iIpnDxIs\",   \"expires_in\": 124234123534,   \"refresh_token\": \"1:GN686QVt0mmakDd9:A4pYuW9LGk0_UnlrMIWklkAuJkUWbq27loFekJVmSYrdfzdePBy7:A-2dHOmBxiXgajnD-kYOwQ\" }<\/code><\/pre>\n<p>token_type &#8212; \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u044f \u0438 \u043d\u0435 \u0432\u0438\u0434\u0435\u043b<\/p>\n<p>access_token &#8212; \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 Oauth \u0442\u043e\u043a\u0435\u043d<\/p>\n<p>expires_in &#8212; \u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430 \u0434\u043e \u043f\u0440\u043e\u0442\u0443\u0445\u0430\u043d\u0438\u044f<\/p>\n<p>refresh_token &#8212; \u0442\u043e\u043a\u0435\u043d \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u043e\u043a\u0435\u043d \u0438 \u0432\u0440\u043e\u0434\u0435 \u043a\u0430\u043a \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0442\u0443\u0445\u0430\u043d\u0438\u044f \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435.<\/p>\n<p>\u041c\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430 \u043d\u0430 PHP. \u0414\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b\u0438\u043a (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 iot_yandex_auth.php) \u043d\u0443\u0436\u043d\u043e (\u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438) \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u0432\u0435\u0431 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u041c\u043e\u0436\u043d\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u044d\u0442\u043e\u0433\u043e \u0438 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043a\u0443\u0440\u043b\u043e\u043c. \u0414\u0430 \u0438 \u0432\u0440\u043e\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e \u0438\u0434\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 iot_yandex_auth.php<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php $client_id=\"&lt;client_id>\"; $client_secret=\"&lt;client_secret>\"; $file=\"private_folder_kae6iev_taex\/iot_yandex_token.json\";  function universal_curl($url,$headers,$data = \"\",$method = \"\"){     $ch = curl_init();     curl_setopt($ch, CURLOPT_URL, $url);     if($method!=\"\"){         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);     }     if($data!=\"\"){         curl_setopt($ch, CURLOPT_POST, 1);         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);     }     curl_setopt($ch, CURLOPT_FAILONERROR, 0);     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt($ch, CURLOPT_VERBOSE, 0);     curl_setopt($ch, CURLOPT_TIMEOUT, 5);     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);     $result = curl_exec($ch);     $result = json_decode($result,true);     curl_close($ch);     return $result; }   if(isset($_GET[\"code\"])&amp;&amp;is_numeric($_GET[\"code\"])){     $auth=base64_encode($client_id.\":\".$client_secret);     $headers=[\"Authorization: Basic \".$auth];     $url=\"https:\/\/oauth.yandex.ru\/token\";     $data=\"grant_type=authorization_code&amp;code=\".$_GET[\"code\"];     $response=universal_curl($url,$headers,$data);     if(isset($response[\"access_token\"])){         $response[\"expires\"]=$response[\"expires_in\"]+time();         if(file_put_contents($file, json_encode($response))){             echo \"Success\";         }         exit;     } }  $url=\"https:\/\/oauth.yandex.ru\/authorize?response_type=code&amp;client_id=\".$client_id.\"&amp;force_confirm=yes&amp;scope=iot:view%20iot:control\"; header('Location: '.$url);<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0438\u0434\u0451\u043c \u043d\u0430 https:\/\/ownsite.ru\/iot_yandex_auth.php<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0432 GET \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043a\u043e\u0434\u0430 \u043d\u0435\u0442, \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0435\u0440\u0435\u0430\u0434\u0440\u0435\u0441\u0443\u0435\u0442 \u043a\u0443\u0434\u0430 \u043d\u0430\u0434\u043e, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c &#8212; \u0442\u043e \u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u042f\u043d\u0434\u0435\u043a\u0441, \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0442\u043e\u043a\u0435\u043d \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442 \u0432 \u043f\u0430\u043f\u043a\u0443 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e $client_id \u0438 $client_secret \u043d\u0430\u0434\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c, \u0430 \u0442\u0430\u043a \u0436\u0435 $file \u043f\u0440\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043f\u0430\u043f\u043a\u0443 \u0432 \/ \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0430\u0439\u0442\u0430. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0430\u0439\u043b\u0438\u043a \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0441\u043e \u0432\u0441\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430, \u0445\u043e\u0440\u043e\u0448\u043e \u0431\u044b \u043f\u0440\u0438\u043a\u0440\u044b\u0442\u044c \u043b\u043e\u043a\u0430\u0446\u0438\u044e \u0438\u043b\u0438 \u043a\u0430\u043a-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041c\u043e\u0436\u043d\u043e \u0438 \u043d\u0443\u0436\u043d\u043e \u0435\u0449\u0435 \u0433\u0434\u0435-\u0442\u043e \u0432\u044b\u0448\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u044b \u043b\u043e\u043a\u0430\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435.<\/p>\n<p>\u0415\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u043e \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431 \u043f\u0440\u0430\u0432\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 $file \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0438 \u0444\u0430\u0439\u043b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c\u0441\u044f &#8212; \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 errors \u0432\u0430\u0448\u0435\u0433\u043e \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>\u0415\u0449\u0435 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 JSON \u0432 \u0444\u0430\u0439\u043b\u0438\u043a, \u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0442\u0443\u0434\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 expires, \u0442.\u043a. \u043c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0438\u043d\u0430\u0447\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0441 expires_in \u0438 \u043a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e\u043a\u0435\u043d \u043f\u0440\u043e\u0441\u0440\u043e\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u044d\u0442\u0430 \u043b\u043e\u043a\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0434\u043b\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0430\u0448\u0438\u043c \u0443\u043c\u043d\u044b\u043c \u0434\u043e\u043c\u043e\u043c.<\/p>\n<h2>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u0441\u0451 \u0433\u043e\u0442\u043e\u0432\u043e, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u0430\u0439\u043b\u0438\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 functions.php &#8212; \u0433\u0434\u0435-\u0442\u043e \u0435\u0449\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \/opt\/scripts\/smart_home<\/p>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c $yandex_iot_client_id, $yandex_iot_client_secret \u0438 $yandex_iot_file \u043d\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 functions.php<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php $yandex_iot_client_id=\"&lt;client_id>\"; $yandex_iot_client_secret=\"&lt;client_secret>\"; $yandex_iot_file=\"\/var\/www\/ownsite.ru\/private_folder_kae6iev_taex\/iot_yandex_token.json\";  function universal_curl($url,$headers,$data = \"\",$method = \"\"){     $ch = curl_init();     curl_setopt($ch, CURLOPT_URL, $url);     if($method!=\"\"){         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);     }     if($data!=\"\"){         curl_setopt($ch, CURLOPT_POST, 1);         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);     }     curl_setopt($ch, CURLOPT_FAILONERROR, 0);     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt($ch, CURLOPT_VERBOSE, 0);     curl_setopt($ch, CURLOPT_TIMEOUT, 5);     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);     $result = curl_exec($ch);     $result = json_decode($result,true);     curl_close($ch);     return $result; }  function universal_yandex_iot($function,$headers_add = array(),$data = \"\",$method = \"\"){     $iot_api_url=\"https:\/\/api.iot.yandex.net\";     $url=$iot_api_url.$function;     $headers=array_merge(array(\"Authorization: Bearer \".get_yandex_iot_token()),$headers_add);     return(universal_curl($url,$headers,$data,$method)); }  function get_yandex_iot_power_state($device_id){     $function=\"\/v1.0\/devices\/\".$device_id;     $result=universal_yandex_iot($function);     if(isset($result[\"capabilities\"])){         foreach($result[\"capabilities\"] as $capability){             if($capability[\"type\"]==\"devices.capabilities.on_off\"){                 if($capability[\"state\"][\"value\"]==\"\"){                     return(0);                 }elseif($capability[\"state\"][\"value\"]==\"1\"){                     return(1);                 }else{                     return(-1);                 }             }         }     }else{         return(-1);     } }  function get_yandex_iot_info(){     $function=\"\/v1.0\/user\/info\";     $result=universal_yandex_iot($function);     return($result); }  function yandex_iot_power_change($device_id,$state){     $function=\"\/v1.0\/devices\/actions\";     $headers=[\"Content-Type: application\/json\"];     $data='{\"devices\":[{\"id\":\"'.$device_id.'\",\"actions\":[{\"type\":\"devices.capabilities.on_off\",\"state\":{\"instance\":\"on\",\"value\":'.$state.'}}]}]}';     $result=universal_yandex_iot($function,$headers,$data);     if(isset($result[\"status\"])&amp;&amp;$result[\"status\"]==\"ok\"){         return(true);     }else{         return(false);     } }  function get_yandex_iot_token(){     global $yandex_iot_file;     $token=file_get_contents($yandex_iot_file);     $token_arr=json_decode($token,true);     if($token_arr[\"expires\"]-time()&lt;20995200){         update_yandex_iot_token();     }     return($token_arr[\"access_token\"]); }  function update_yandex_iot_token(){     global $yandex_iot_file,$yandex_iot_client_id,$yandex_iot_client_secret;     $token=file_get_contents($yandex_iot_file);     $token_arr=json_decode($token,true);     $url=\"https:\/\/oauth.yandex.ru\/token\";     $auth=base64_encode($yandex_iot_client_id.\":\".$yandex_iot_client_secret);     $headers=[\"Authorization: Basic \".$auth,\"application\/x-www-form-urlencoded\"];     $data=\"grant_type=refresh_token&amp;refresh_token=\".$token_arr[\"refresh_token\"];     $response=universal_curl($url,$headers,$data);     if(isset($response[\"access_token\"])){         $response[\"expires\"]=$response[\"expires_in\"]+time();         if(file_put_contents($yandex_iot_file, json_encode($response))){             return(true);         }     }else{         return(false);     } } ?><\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>universal_curl &#8212; \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u0443\u0440\u043b<\/p>\n<p>universal_yandex_iot &#8212; \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0443\u0440\u043b\u0430 \u0434\u043b\u044f \u042f\u043d\u0434\u0435\u043a\u0441\u0430<\/p>\n<p>get_yandex_iot_power_state &#8212; \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0438\u0442\u0430\u043d\u0438\u044f<\/p>\n<p>get_yandex_iot_info &#8212; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u0443\u043c\u043d\u043e\u043c\u0443 \u0434\u043e\u043c\u0443, \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, device_id \u0438 \u043f\u0440\u043e\u0447\u0435\u0435.<\/p>\n<p>yandex_iot_power_change &#8212; \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0438\u0442\u0430\u043d\u0438\u044f<\/p>\n<p>get_yandex_iot_token &#8212; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u043e\u043a\u0435\u043d \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 (\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f), \u0435\u0441\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u0442\u043e\u043a\u0435\u043d\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0435\u043c 8 \u043c\u0435\u0441\u044f\u0446\u0435\u0432.<\/p>\n<p>update_yandex_iot_token &#8212; \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430 (\u043f\u043e\u043f\u044b\u0442\u043a\u0430). \u0422\u0443\u0442 \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 JSON \u0432 \u0444\u0430\u0439\u043b\u0438\u043a, \u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0442\u0443\u0434\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 expires, \u0442.\u043a. \u043c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0438\u043d\u0430\u0447\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0441 expires_in \u0438 \u043a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e\u043a\u0435\u043d \u043f\u0440\u043e\u0441\u0440\u043e\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 yandex_test.php.<\/p>\n<pre><code class=\"php\">&lt;?php require_once('functions.php');  \/\/print_r(get_yandex_iot_info()); \/\/exit; echo get_yandex_iot_power_state(\"&lt;device_id>\").\"\\n\"; echo yandex_iot_power_change(\"&lt;device_id>\",\"false\").\"\\n\"; sleep(1); echo get_yandex_iot_power_state(\"&lt;device_id>\").\"\\n\"; echo yandex_iot_power_change(\"&lt;device_id>\",\"true\").\"\\n\"; ?><\/code><\/pre>\n<p>\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c-\u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c, \u0440\u0430\u0434\u0443\u0435\u043c\u0441\u044f \u0447\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438 sleep(1) &#8212; \u044d\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431 \u042f\u043d\u0434\u0435\u043a\u0441 \u0443 \u0441\u0435\u0431\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043f\u0435\u043b \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441. \u041d\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u0442\u0430\u043d\u0438\u0435\u043c, \u043d\u043e \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438\u0437\u0443\u0447\u0438\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e <a href=\"https:\/\/yandex.ru\/dev\/dialogs\/smart-home\/doc\/concepts\/platform-protocol.html\" rel=\"noopener noreferrer nofollow\">https:\/\/yandex.ru\/dev\/dialogs\/smart-home\/doc\/concepts\/platform-protocol.html<\/a>. \u041c\u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0438\u0442\u0430\u043d\u0438\u0435\u043c, \u043d\u043e \u0438\u043c\u0435\u044f \u0431\u0430\u0437\u0443 &#8212; \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0434\u043e\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0440\u0443\u0434\u0430.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/789200\/\"> https:\/\/habr.com\/ru\/articles\/789200\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u0439\u0434\u0451\u0442 \u0440\u0435\u0447\u044c \u043e \u0441\u0430\u043c\u043e\u043c \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0430 \u042f\u043d\u0434\u0435\u043a\u0441 &#8212; \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\/\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0442.\u043a. \u043d\u0438\u0447\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u043d\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043d\u043e \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438. \u041c\u043e\u0436\u0435\u0442 \u044d\u0442\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043d\u0435 \u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044e \u0432\u043e\u0432\u0441\u0435, \u043d\u043e \u0432\u043e\u0442 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f. \u0417\u0430 \u043a\u043e\u0434 \u043d\u0435 \u0440\u0443\u0433\u0430\u0439\u0442\u0435 \u0441\u0438\u043b\u044c\u043d\u043e &#8212; \u044f \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442. \u041a\u043e\u0434 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c PHP.<\/p>\n<figure class=\"\">\n<div><figcaption>AI: \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0430 \u0441\u0432\u043e\u0438\u043c\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438 \u043d\u0430 PHP<\/figcaption><\/div>\n<\/figure>\n<h2>\u0417\u0430\u0447\u0435\u043c?<\/h2>\n<p>\u0417\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043c\u043d\u0435 \u043a\u0430\u043a-\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0410\u043b\u0438\u0441\u0443. \u0410 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445? \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u044b. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0433\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043f\u0438\u043a\u043e\u0432\u044b\u0439 \u0442\u0430\u0440\u0438\u0444 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u044d\u043d\u0435\u0440\u0433\u0438\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0440\u0451\u0445\u0442\u0430\u0440\u0438\u0444\u043d\u043e\u0433\u043e \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u043f\u0438\u043a\u043e\u0432\u043e\u0433\u043e \u0442\u0430\u0440\u0438\u0444\u044b, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u044b\u043b \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0434\u043e \u044d\u0442\u043e\u0433\u043e.<\/p>\n<p>\u0414\u0430, \u0432 \u043c\u0438\u0440\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u0435\u0449\u0438 \u0442\u0438\u043f\u0430 Home Assistant, \u043d\u043e \u043f\u043e\u043a\u0430 \u043c\u043d\u0435 \u043b\u0435\u043d\u044c \u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u0434\u0430 \u0438 \u043a\u0430\u043a-\u0442\u043e \u043e\u0431\u0445\u043e\u0434\u0438\u043b\u0441\u044f \u0431\u0435\u0437 \u043d\u0435\u0433\u043e. \u041f\u043e\u043a\u0430 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u0435 \u043e\u0441\u043e\u0437\u043d\u0430\u043b, \u0437\u0430\u0447\u0435\u043c \u043e\u043d \u043c\u043d\u0435. \u0418 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0442\u0430\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u0412\u0430\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u0434\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0431\u044b\u043b \u0432\u043a\u043b\u044e\u0447\u0435\u043d. \u0415\u0441\u043b\u0438 \u0434\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u043f\u0438\u043a\u043e\u0432\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u0438\u0431\u043e\u0440 \u043d\u0435 \u0431\u044b\u043b \u0432\u043a\u043b\u044e\u0447\u0435\u043d, \u0442\u043e \u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0435 \u043d\u0430\u0434\u043e \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u043f\u0438\u043a\u043e\u0432\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<h2>\u041f\u043e\u0438\u0441\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/h2>\n<p>\u041d\u0430\u0447\u0430\u0442\u044c \u0440\u0435\u0448\u0438\u043b \u0441 API \u042f\u043d\u0434\u0435\u043a\u0441\u0430. \u0411\u043b\u0430\u0433\u043e \u0441 \u044d\u0442\u0438\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435\u0442, \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e:<\/p>\n<p><a href=\"https:\/\/yandex.ru\/dev\/dialogs\/smart-home\/doc\/concepts\/platform-quickstart.html\" rel=\"noopener noreferrer nofollow\">https:\/\/yandex.ru\/dev\/dialogs\/smart-home\/doc\/concepts\/platform-quickstart.html<\/a><\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043a\u0443\u0434\u043d\u0430 \u043d\u0430 \u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b. <\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u0435\u0435 \u0434\u0435\u043b\u043e &#8212; \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0441\u0432\u043e\u0451, \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0447\u0442\u043e-\u0442\u043e \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u043d\u0430 Github \u0438\u043b\u0438 \u0435\u0449\u0435 \u0433\u0434\u0435-\u0442\u043e. \u0427\u0435\u0441\u0442\u043d\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u044e\u0441\u044c, \u0438\u0441\u043a\u0430\u043b \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0433\u043b\u0443\u0431\u043e\u043a\u043e, \u043d\u043e \u043d\u0430\u0442\u044b\u043a\u0430\u043b\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u0439 &#171;\u0443\u043c\u043d\u044b\u0439 \u0434\u043e\u043c&#187; \u043a \u0410\u043b\u0438\u0441\u0435, \u0447\u0442\u043e \u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437 \u0410\u043b\u0438\u0441\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438.<\/p>\n<h2>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041a\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 oauth \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"https:\/\/oauth.yandex.ru\/client\/new\/\" rel=\"noopener noreferrer nofollow\">https:\/\/oauth.yandex.ru\/client\/new\/<\/a><\/p>\n<p>\u0412\u0430\u0436\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u0431\u0435\u0437\u0434\u0430\u0440\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432. \u041d\u0443\u0436\u043d\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u0430 \u043d\u0435 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043d\u0430\u0436\u0438\u043c\u0430\u0442\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 &#171;\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435&#187; &#8212; \u043e\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 &#171;id&#187;, \u0432 url \u0432\u0438\u0434\u043d\u043e \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 <a href=\"https:\/\/oauth.yandex.ru\/client\/new\/id\" rel=\"noopener noreferrer nofollow\">https:\/\/oauth.yandex.ru\/client\/new\/id<\/a> \u0438 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f oauth Yandex<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043b\u044e\u0431\u043e\u0435.<\/p>\n<p>\u0413\u0430\u043b\u043e\u0447\u043a\u0430 &#8212; \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u044b.<\/p>\n<p>Redirect URI &#8212; \u0441\u0441\u044b\u043b\u043a\u0430, \u043a\u0443\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0430\u0434\u0440\u0435\u0441\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043d\u0430 \u043c\u043e\u0451\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/oauth.yandex.ru\/verification_code\" rel=\"noopener noreferrer nofollow\">http:\/\/oauth.yandex.ru\/verification_code<\/a> &#8212; \u044d\u0442\u043e\u0442 URL \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043a\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c &#8212; \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: <code>iot:view<\/code>,\u00a0<code>iot:control<\/code><\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043d\u0430\u0434\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0442\u043e\u043a\u0435\u043d \u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u0433\u043e\u0434, \u0437\u0430\u0442\u0435\u043c \u0435\u0433\u043e \u0432\u0440\u043e\u0434\u0435 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043b\u044f\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b, \u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0435\u0433\u043e:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 ClientID \u0438 Client secret &#8212; \u043e\u043d\u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f. \u041c\u043e\u0436\u043d\u043e \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c &#8212; \u043e\u043d\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h2>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430<\/h2>\n<p>\u0418\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a<\/p>\n<pre><code class=\"bash\">$ curl \"https:\/\/oauth.yandex.ru\/authorize?response_type=code&amp;client_id=&lt;client_id>&amp;force_confirm=no&amp;scope=iot:view%20iot:control\" Found. Redirecting to https:\/\/passport.yandex.ru\/auth?retpath=https%3A%2F%2Foauth.yandex.ru%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3D%253Cclient_id%253E%26force_confirm%3Dno%26scope%3Diot%3Aview%2520iot%3Acontrol&amp;noreturn=1&amp;origin=oauth<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0451\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u043e:<\/p>\n<p><a href=\"https:\/\/passport.yandex.ru\/auth?retpath=https%3A%2F%2Foauth.yandex.ru%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3D%253Cclient_id%253E%26force_confirm%3Dno%26scope%3Diot%3Aview%2520iot%3Acontrol&amp;noreturn=1&amp;origin=oauth\" rel=\"noopener noreferrer nofollow\">https:\/\/passport.yandex.ru\/auth?retpath=https%3A%2F%2Foauth.yandex.ru%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3D%253Cclient_id%253E%26force_confirm%3Dno%26scope%3Diot%3Aview%2520iot%3Acontrol&amp;noreturn=1&amp;origin=oauth<\/a><\/p>\n<p>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0443\u0435\u043c\u0441\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u0434 &#8212; \u043a\u043e\u0434 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 <a href=\"http:\/\/oauth.yandex.ru\/verification_code\" rel=\"noopener noreferrer nofollow\">http:\/\/oauth.yandex.ru\/verification_code<\/a> , \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0449\u0435 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432\u0430 \u0431\u043e\u043b\u0435\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441 \u044d\u0442\u0438\u043c \u043a\u043e\u0434\u043e\u043c, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0430\u043c \u0442\u043e\u043a\u0435\u043d:<\/p>\n<pre><code>curl -H \"Authorization: Basic $(echo -n \"&lt;ClientID>:&lt;Client secret>\"|base64 -w 0)\" -d \"grant_type=authorization_code&amp;code=&lt;code>\" \"https:\/\/oauth.yandex.ru\/token\"<\/code><\/pre>\n<p>\u0412 \u043e\u0442\u0432\u0435\u0442 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 JSON \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n<pre><code class=\"json\">{   \"token_type\": \"bearer\",   \"access_token\": \"AQAAAACy1C6ZAAAAfa6vDLuItEy8pg-iIpnDxIs\",   \"expires_in\": 124234123534,   \"refresh_token\": \"1:GN686QVt0mmakDd9:A4pYuW9LGk0_UnlrMIWklkAuJkUWbq27loFekJVmSYrdfzdePBy7:A-2dHOmBxiXgajnD-kYOwQ\" }<\/code><\/pre>\n<p>token_type &#8212; \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u044f \u0438 \u043d\u0435 \u0432\u0438\u0434\u0435\u043b<\/p>\n<p>access_token &#8212; \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 Oauth \u0442\u043e\u043a\u0435\u043d<\/p>\n<p>expires_in &#8212; \u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430 \u0434\u043e \u043f\u0440\u043e\u0442\u0443\u0445\u0430\u043d\u0438\u044f<\/p>\n<p>refresh_token &#8212; \u0442\u043e\u043a\u0435\u043d \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u043e\u043a\u0435\u043d \u0438 \u0432\u0440\u043e\u0434\u0435 \u043a\u0430\u043a \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0442\u0443\u0445\u0430\u043d\u0438\u044f \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435.<\/p>\n<p>\u041c\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430 \u043d\u0430 PHP. \u0414\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b\u0438\u043a (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 iot_yandex_auth.php) \u043d\u0443\u0436\u043d\u043e (\u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438) \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u0432\u0435\u0431 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u041c\u043e\u0436\u043d\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u044d\u0442\u043e\u0433\u043e \u0438 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043a\u0443\u0440\u043b\u043e\u043c. \u0414\u0430 \u0438 \u0432\u0440\u043e\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e \u0438\u0434\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 iot_yandex_auth.php<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php $client_id=\"&lt;client_id>\"; $client_secret=\"&lt;client_secret>\"; $file=\"private_folder_kae6iev_taex\/iot_yandex_token.json\";  function universal_curl($url,$headers,$data = \"\",$method = \"\"){     $ch = curl_init();     curl_setopt($ch, CURLOPT_URL, $url);     if($method!=\"\"){         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);     }     if($data!=\"\"){         curl_setopt($ch, CURLOPT_POST, 1);         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);     }     curl_setopt($ch, CURLOPT_FAILONERROR, 0);     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt($ch, CURLOPT_VERBOSE, 0);     curl_setopt($ch, CURLOPT_TIMEOUT, 5);     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);     $result = curl_exec($ch);     $result = json_decode($result,true);     curl_close($ch);     return $result; }   if(isset($_GET[\"code\"])&amp;&amp;is_numeric($_GET[\"code\"])){     $auth=base64_encode($client_id.\":\".$client_secret);     $headers=[\"Authorization: Basic \".$auth];     $url=\"https:\/\/oauth.yandex.ru\/token\";     $data=\"grant_type=authorization_code&amp;code=\".$_GET[\"code\"];     $response=universal_curl($url,$headers,$data);     if(isset($response[\"access_token\"])){         $response[\"expires\"]=$response[\"expires_in\"]+time();         if(file_put_contents($file, json_encode($response))){             echo \"Success\";         }         exit;     } }  $url=\"https:\/\/oauth.yandex.ru\/authorize?response_type=code&amp;client_id=\".$client_id.\"&amp;force_confirm=yes&amp;scope=iot:view%20iot:control\"; header('Location: '.$url);<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0438\u0434\u0451\u043c \u043d\u0430 https:\/\/ownsite.ru\/iot_yandex_auth.php<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0432 GET \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043a\u043e\u0434\u0430 \u043d\u0435\u0442, \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0435\u0440\u0435\u0430\u0434\u0440\u0435\u0441\u0443\u0435\u0442 \u043a\u0443\u0434\u0430 \u043d\u0430\u0434\u043e, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c &#8212; \u0442\u043e \u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u042f\u043d\u0434\u0435\u043a\u0441, \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0442\u043e\u043a\u0435\u043d \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442 \u0432 \u043f\u0430\u043f\u043a\u0443 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e $client_id \u0438 $client_secret \u043d\u0430\u0434\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c, \u0430 \u0442\u0430\u043a \u0436\u0435 $file \u043f\u0440\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043f\u0430\u043f\u043a\u0443 \u0432 \/ \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0430\u0439\u0442\u0430. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0430\u0439\u043b\u0438\u043a \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0441\u043e \u0432\u0441\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430, \u0445\u043e\u0440\u043e\u0448\u043e \u0431\u044b \u043f\u0440\u0438\u043a\u0440\u044b\u0442\u044c \u043b\u043e\u043a\u0430\u0446\u0438\u044e \u0438\u043b\u0438 \u043a\u0430\u043a-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041c\u043e\u0436\u043d\u043e \u0438 \u043d\u0443\u0436\u043d\u043e \u0435\u0449\u0435 \u0433\u0434\u0435-\u0442\u043e \u0432\u044b\u0448\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u044b \u043b\u043e\u043a\u0430\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435.<\/p>\n<p>\u0415\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u043e \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431 \u043f\u0440\u0430\u0432\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 $file \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0438 \u0444\u0430\u0439\u043b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c\u0441\u044f &#8212; \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 errors \u0432\u0430\u0448\u0435\u0433\u043e \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>\u0415\u0449\u0435 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 JSON \u0432 \u0444\u0430\u0439\u043b\u0438\u043a, \u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0442\u0443\u0434\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 expires, \u0442.\u043a. \u043c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0438\u043d\u0430\u0447\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0441 expires_in \u0438 \u043a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e\u043a\u0435\u043d \u043f\u0440\u043e\u0441\u0440\u043e\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u044d\u0442\u0430 \u043b\u043e\u043a\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0434\u043b\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0430\u0448\u0438\u043c \u0443\u043c\u043d\u044b\u043c \u0434\u043e\u043c\u043e\u043c.<\/p>\n<h2>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u0441\u0451 \u0433\u043e\u0442\u043e\u0432\u043e, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u0430\u0439\u043b\u0438\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 functions.php &#8212; \u0433\u0434\u0435-\u0442\u043e \u0435\u0449\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \/opt\/scripts\/smart_home<\/p>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c $yandex_iot_client_id, $yandex_iot_client_secret \u0438 $yandex_iot_file \u043d\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 functions.php<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php $yandex_iot_client_id=\"&lt;client_id>\"; $yandex_iot_client_secret=\"&lt;client_secret>\"; $yandex_iot_file=\"\/var\/www\/ownsite.ru\/private_folder_kae6iev_taex\/iot_yandex_token.json\";  function universal_curl($url,$headers,$data = \"\",$method = \"\"){     $ch = curl_init();     curl_setopt($ch, CURLOPT_URL, $url);     if($method!=\"\"){         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);     }     if($data!=\"\"){         curl_setopt($ch, CURLOPT_POST, 1);         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);     }     curl_setopt($ch, CURLOPT_FAILONERROR, 0);     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt($ch, CURLOPT_VERBOSE, 0);     curl_setopt($ch, CURLOPT_TIMEOUT, 5);     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);     $result = curl_exec($ch);     $result = json_decode($result,true);     curl_close($ch);     return $result; }  function universal_yandex_iot($function,$headers_add = array(),$data = \"\",$method = \"\"){     $iot_api_url=\"https:\/\/api.iot.yandex.net\";     $url=$iot_api_url.$function;     $headers=array_merge(array(\"Authorization: Bearer \".get_yandex_iot_token()),$headers_add);     return(universal_curl($url,$headers,$data,$method)); }  function get_yandex_iot_power_state($device_id){     $function=\"\/v1.0\/devices\/\".$device_id;     $result=universal_yandex_iot($function);     if(isset($result[\"capabilities\"])){         foreach($result[\"capabilities\"] as $capability){             if($capability[\"type\"]==\"devices.capabilities.on_off\"){                 if($capability[\"state\"][\"value\"]==\"\"){                     return(0);                 }elseif($capability[\"state\"][\"value\"]==\"1\"){                     return(1);                 }else{                     return(-1);                 }             }         }     }else{         return(-1);     } }  function get_yandex_iot_info(){     $function=\"\/v1.0\/user\/info\";     $result=universal_yandex_iot($function);     return($result); }  function yandex_iot_power_change($device_id,$state){     $function=\"\/v1.0\/devices\/actions\";     $headers=[\"Content-Type: application\/json\"];<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-366430","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/366430","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=366430"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/366430\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=366430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=366430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=366430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}