{"id":298446,"date":"2020-02-10T09:00:17","date_gmt":"2020-02-10T09:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=298446"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-02-10T09:00:17","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=298446","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e Viberbot. \u0427\u0430\u0441\u0442\u044c \u0432\u0442\u043e\u0440\u0430\u044f \u2014 \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0430\u043a\u0442 \u0438\u043b\u0438 \u00ab\u0441onversation_started\u00bb"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/486858\/\">\n<h3>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u2014 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u043c \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c<\/h3>\n<p>  \u0412 <a href=\"https:\/\/habr.com\/ru\/post\/486826\/\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c <s>\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u0435\u0440<\/s> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c webhook \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 botviber.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 2-\u0439 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0435 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u043a\u0430\u043a \u0432\u043d\u0443\u0442\u0440\u0438 ViberURL \u0442\u0430\u043a \u0438 NoViberURL<\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0421\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0431\u043e\u0442\u0430<\/h4>\n<p>  1) O\u0444\u0444\u043b\u0430\u0439\u043d QR \u2014 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0438\u0437 \u043f\u0430\u0440\u0442\u043d\u0435\u0440\u0441\u043a\u043e\u0439 \u0430\u0434\u043c\u0438\u043d\u043a\u0438 <a href=\"https:\/\/partners.viber.com\/login\" rel=\"nofollow\">viber<\/a><\/p>\n<p>  2) \u0421\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u043c\u0435\u0441c\u0435\u043d\u0434\u0436\u0435\u0440\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u043e \u043c\u0435\u0441\u0441\u0435\u043d\u0434\u0436\u0435\u0440\u0443 ViberURL<br \/>  <code>viber:\/\/pa?chatURI=dinner&amp;context=fromhabr<\/code><\/p>\n<p>  3) \u0421\u0441\u044b\u043b\u043a\u0430 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 <a href=\"https:\/\/botviber.ru\/foot.php\" rel=\"nofollow\">NoViberURL<\/a> \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043c\u043d\u043e\u0433\u043e \u0442\u0430\u043a\u0438\u0445 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u0435\u043b\u0435\u0439 URL \u2014 \u043d\u043e \u0432\u0441\u0435 \u043e\u043d\u0438 \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 \u0441\u043f\u0430\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u0434 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0441\u0442\u0440\u043e\u043a PHP \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0441\u0435\u0431\u0435 \u043d\u0430 \u0445\u043e\u0441\u0442\u0438\u043d\u0433, \u0432\u043e\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 foot.php  <\/p>\n<pre><code class=\"php\">&lt;?php header (&quot;Location: viber:\/\/pa?chatURI=dinner&quot;); exit();<\/code><\/pre>\n<h4>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f botviber \u0438\u043b\u0438 \u00abevent\u00bb: \u00abconversation_started\u00bb<\/h4>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f QR \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 \u0430\u0434\u0440\u0435\u0441 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 Viber (Jetty) \u043f\u0440\u0438\u043b\u0435\u0442\u0430\u044e\u0442 POST \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u0441\u043e\u0431\u044b\u0442\u0438\u0435\u043c (\u00abevent\u00bb: \u00abconversation_started\u00bb) \u0430 \u0438\u0445 \u043f\u043e\u043b\u043d\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u0425\u041e\u0414\u042f\u0429\u0418\u0415 \u041f\u0410\u0420\u0410\u041c\u0415\u0422\u0420\u042b POST &#8212; \u0438\u043b\u0438 JSON \u0438\u0437 13 \u043f\u043e\u043b\u0435\u0439<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">{   &quot;chat_hostname&quot;: &quot;SN-327_&quot;, # \u0415\u0441\u043b\u0438 Viber \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u0445 - \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 &quot;chat_hostname&quot;   &quot;event&quot;: &quot;conversation_started&quot;, # \u0421\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u043b\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u043e\u0442\u0430 \u043d\u0430 \u0441\u0442\u0440\u043e\u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f    &quot;context&quot;: &quot;fromlanding&quot;, # \u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c UTM \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0441\u0441\u044b\u043b\u043a\u0438     &quot;message_token&quot;: 5406893180055821524, # \u0442\u043e\u043a\u0435\u043d \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f   &quot;subscribed&quot;: false, # \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0435\u0449\u0435 \u043d\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d, \u0435\u0441\u043b\u0438 \u0442\u0443\u0442 true \u0442\u043e \u0443\u0436\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d   &quot;timestamp&quot;: 1581161565470, # UNIXTIME    &quot;type&quot;: &quot;open&quot;, # \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0434\u0438\u0430\u043b\u043e\u0433\u0430   &quot;user&quot;: {     &quot;api_version&quot;: 8,  # \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f API \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.      &quot;avatar&quot;: &quot;https:\/\/media-direct.cdn.viber.com\/avatar...&quot;, # \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0432\u0430\u0442\u0430\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f - \u0443 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0445 \u043f\u0443\u0441\u0442\u043e, \u043f\u043e\u043b\u044f \u0430\u0432\u0430\u0442\u0430\u0440 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442     &quot;country&quot;: &quot;RU&quot;, # \u041f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043a \u0441\u0442\u0440\u0430\u043d\u0435 (UA-\u0443\u043a\u0440\u0430\u0438\u043d\u0430, BY-\u0431\u0435\u043b\u0430\u0440\u0443\u0441\u044c, IL-\u0438\u0437\u0440\u0430\u0438\u043b\u044c, MD - \u043c\u043e\u043b\u0434\u043e\u0432\u0430)     &quot;id&quot;: &quot;J2k6sasdgghaazDeoXVYww==&quot;, # ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0412\u0410\u0428\u0415\u041c \u0431\u043e\u0442\u0435     &quot;language&quot;: &quot;ru&quot;, # \u042f\u0437\u044b\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u044f\u0437\u044b\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430(\u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442)     &quot;name&quot;: &quot;Denis&quot; \u2116 #\u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 Viber - \u0442\u043e \u043a\u0430\u043a \u043e\u043d \u0441\u0435\u0431\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043b - \u0443 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0445 \u043f\u0443\u0441\u0442\u043e \u043f\u043e\u043b\u044f name \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442   } }<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0438 5 \u043f\u043e\u043b\u0435\u0439<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">{   &quot;context&quot;: &quot;fromlanding&quot;, # \u0414\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0445 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0439    &quot;subscribed&quot;: false,    &quot;user&quot;: {     &quot;country&quot;: &quot;RU&quot;, # \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0440\u0430\u043d\u0430 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f     &quot;id&quot;: &quot;J2k6sasdgghaazDeoXVYww==&quot;, # ID \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432 \u0411\u0414     &quot;name&quot;: &quot;Denis&quot; \u2116 #\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0435\u0441\u0442\u044c.   } }<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0410 \u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e \u043f\u043e\u043b\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\u00abid\u00bb: \u00abJ2k6sasdgghaazDeoXVYww==\u00bb  <\/div>\n<\/div>\n<p>  \u044d\u0442\u043e \u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 Viber \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430\u043d\u0430\u043b\u043e\u0433 chat_id \u0432 telegram.   <\/p>\n<blockquote><p>\u0418, \u043f\u0440\u043e\u0448\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u0442\u0435\u043b\u0435\u0433\u0435 chat_id \u043e\u0434\u0438\u043d \u043f\u043e \u0432\u0441\u0435\u0439 \u0441\u0435\u0442\u0438 \u043c\u0435\u0441\u0441\u0435\u043d\u0434\u0436\u0435\u0440\u0430 \u0432\u043e \u0432\u0441\u0435\u0445 \u0432\u0441\u0435\u0445 \u0431\u043e\u0442\u0430\u0445 \u2014 \u043a\u0430\u043a \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440, \u0430 \u0443 \u0432\u0430\u0439\u0431\u0435\u0440 id \u2014 \u043e\u043d \u043a\u0430\u043a \u0442\u043e\u043a\u0435\u043d \u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u0435\u043d \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430. \u0412 \u0434\u0440\u0443\u0433\u043e\u043c \u0431\u043e\u0442\u0435 \u0432\u0430\u0448 id \u0441\u0442\u0430\u043d\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u043c\u2026   <\/p><\/blockquote>\n<p>  \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0438\u0445 \u0438 \u043e\u0442\u0432\u0435\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0442\u0440\u0435\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0438\u0436\u0435 \u2014 \u043c\u044b \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043a\u0430\u043a \u041f\u0415\u0420\u0412\u042b\u0419 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043a\u0440\u0438\u043d\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ci\/k4\/py\/cik4pyycxovsxsmki6rjrtupv6a.jpeg\" alt=\"image\"><\/p>\n<blockquote><p>\u041a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0438\u043c botviber \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0431\u0440\u0435\u043d\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043b\u044e\u0431\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u0438\u0431\u043e \u043c\u0438\u043d\u0438 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0447\u0438\u043a, \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u043e\u0433\u043d\u0430\u0442\u044c \u0441\u0442\u0438\u043b\u0438 \u043f\u043e\u0434 \u0432\u0430\u0448 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0430\u0439\u0442<\/p><\/blockquote>\n<p>  1) \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u0444\u0430\u0439\u043b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 myviberbot\/views.py \u0432\u043d\u0435\u0441\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\"> #  import requests # \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432  import json  from django.shortcuts import HttpResponse from django.views.decorators.csrf import csrf_exempt  auth_token = '45df835d27d01f-cd2e7wetwerga18a8-9a7wert786234' #!\u0422\u041e\u041a\u0415\u041d \u0421\u0422\u0410\u0412\u0418\u041c \u0421\u0412\u041e\u0419 \u042d\u0422\u041e \u0424\u0435\u0439\u043a\u043e\u0432\u044b\u0439 \u043d\u0435\u0436\u0438\u0432\u043e\u0439 url = 'https:\/\/chatapi.viber.com\/pa\/send_message' headers = {'X-Viber-Auth-Token': auth_token}  # \u0414\u0415\u041a\u041e\u0420\u0410\u0422\u041e\u0420 \u0414\u041b\u042f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 def sending(func):     def wrapped(*args):         return requests.post(url, json.dumps(func(*args)), headers=headers)     return wrapped  # \u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 @sending def send_text(agent, text, track=None):     m = dict(receiver=agent, min_api_version=2, tracking_data=track, type=&quot;text&quot;, text=text)     return m  @csrf_exempt def trx_bot(request):     if request.method == &quot;POST&quot;:         viber = json.loads(request.body.decode('utf-8'))         if viber['event'] == 'conversation_started':             print(&quot;\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f&quot;)             conversation(viber) #\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 - \u043e\u0431\u0437\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0430\u0431\u0437\u0430\u0446.         elif viber['event'] == 'webhook':             #print(viber)             #print(&quot;Webhook \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d&quot;)             return HttpResponse(status=200)         else:             print(&quot;\u042d\u0442\u043e \u043d\u0435 Webhook - \u043f\u0440\u043e\u0431\u0443\u0439 \u0435\u0449\u0435 \u0440\u0430\u0437, \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 POSTMAN&quot;)              return HttpResponse(status=500)         return HttpResponse(status=200)   def conversation(viber):     id = viber['user']['id']     if viber['subscribed']: \t    send_text(id, '\u0412\u042b \u0423\u0416\u0415 \u041f\u041e\u0414\u041f\u0418\u0421\u0410\u041d\u042b')     else:         send_text(id, '\u0427\u0442\u043e \u0443\u043c\u0435\u0435\u0442 \u044d\u0442\u043e\u0442 \u0431\u043e\u0442?\\n\\n\u0417\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0430\u0448\u0438\u0445 \u0438\u0434\u0435\u0439. \u041e\u0442\u043f\u0440\u0430\u0432\u044c \u043c\u043d\u0435 \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u0438 \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0441\u044f...')  <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 Django.<\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u00abRakuten Viber\u00bb \u043d\u0438\u043a\u043e\u043c\u0443 \u043d\u0435 \u0434\u0430\u0435\u0442 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0430 PA \u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e, \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u0440\u0443\u043f\u043d\u044b\u0435 \u0431\u0440\u0435\u043d\u0434\u044b \u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043b\u0438\u0447\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f SEO \u043f\u0440\u043e\u0434\u0432\u0438\u0434\u0435\u043d\u0438\u044f \u0438 PR \u043f\u043e \u0441\u043e\u0446\u0441\u0435\u0442\u044f\u043c \u0438 \u0434\u0440. \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043b\u0435\u043d\u0434\u0438\u043d\u0433 \u2014 \u043c\u0435\u043b\u043a\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f\u0442 \u0432\u0441\u0435 \u0441 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430 \u0438\u043b\u0438 \u0434\u0440. \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0432\u043e\u0442 \u043e\u0431\u0440\u0430\u0437\u0435\u0446:<\/p>\n<p>  <a href=\"https:\/\/botviber.ru\/radio\" rel=\"nofollow\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/le\/f8\/jp\/lef8jpeb1jvzrdzheg-qqbtf3eq.jpeg\"><br \/>  <\/a><\/p>\n<p>  <cut><\/cut><\/p>\n<p>  \u0423\u0434\u0430\u0447\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 botviber.<br \/>  \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442\u2026<\/p>\n<p>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c event[\u00abmessage\u00bb], \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e\u0431 \u0432\u0435\u0441\u0442\u0438 \u0434\u0438\u0430\u043b\u043e\u0433, \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0432\u043e\u043e\u0431\u0449\u0435 \u043a\u0430\u043a botviber \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435. <\/p>\n<p>  (\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e Viberbot \u043d\u0430 Django 2 \u0438 Viber REST API. \u0427\u0430\u0441\u0442\u044c \u0442\u0440\u0435\u0442\u044c\u044f \u2014 Message)<\/p>\n<p>  \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b:<br \/>  <a href=\"http:\/\/developers.viber.com\/docs\/api\/rest-bot-api\/\" rel=\"nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f viber REST API<\/a><br \/>  <a href=\"https:\/\/docs.djangoproject.com\/en\/2.2\/\" rel=\"nofollow\">Django \u0432\u0435\u0440\u0441\u0438\u0438 2.2<\/a><br \/>  <a href=\"https:\/\/botviber.ru\/radio\" rel=\"nofollow\">\u0420\u0430\u0434\u0438\u043e\u0432\u0430\u0439\u0431\u0435\u0440-\u043c\u0438\u043d\u0438\u043b\u0435\u043d\u0434\u0438\u043d\u0433<\/a><\/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\/post\/486858\/\"> https:\/\/habr.com\/ru\/post\/486858\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/486858\/\">\n<h3>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u2014 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u043c \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c<\/h3>\n<p>  \u0412 <a href=\"https:\/\/habr.com\/ru\/post\/486826\/\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c <s>\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u0435\u0440<\/s> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c webhook \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 botviber.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 2-\u0439 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0435 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u043a\u0430\u043a \u0432\u043d\u0443\u0442\u0440\u0438 ViberURL \u0442\u0430\u043a \u0438 NoViberURL<\/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-298446","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298446","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=298446"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298446\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}