
{"id":6896,"date":"2019-11-08T04:12:34","date_gmt":"2019-11-08T04:12:34","guid":{"rendered":"http:\/\/tapchicntt.com\/?p=6896"},"modified":"2023-08-12T12:08:58","modified_gmt":"2023-08-12T05:08:58","slug":"huong-dan-tao-google-recaptcha-v3","status":"publish","type":"post","link":"https:\/\/tapchicntt.com\/huong-dan-tao-google-recaptcha-v3\/","title":{"rendered":"H\u01b0\u1edbng d\u1eabn t\u1ea1o Google reCAPTCHA V3"},"content":{"rendered":"\n<p>Google \u0111\u00e3 ra m\u1eaft reCAPTCHA v3 \u0111\u1ec3 ng\u0103n ch\u1eb7n c\u00e1c bot spam m\u00e0 kh\u00f4ng c\u00f3 b\u1ea5t k\u1ef3 s\u1ef1 t\u01b0\u01a1ng t\u00e1c n\u00e0o c\u1ee7a ng\u01b0\u1eddi d\u00f9ng. reCAPTCHA v3 tr\u1ea3 l\u1ea1i cho ch\u00fang t\u00f4i c\u00e1c th\u01b0 r\u00e1c \u0111\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c t\u00e1c v\u1ee5 kh\u00e1c nhau trong \u1ee9ng d\u1ee5ng web c\u1ee7a b\u1ea1n.<\/p>\n\n\n\n<p>B\u00e0i h\u01b0\u1edbng d\u1eabn n\u00e0y, t\u00f4i s\u1ebd h\u01b0\u1edbng d\u1eabn cho b\u1ea1n c\u00e1ch t\u00edch h\u1ee3p Google reCAPTCHA v3 v\u00e0o trang web c\u1ee7a b\u1ea1n.<\/p>\n\n\n\n<p class=\"align-center\"><a class=\"btn btn-danger\" href=\"https:\/\/lyminhhoang.com\">Demo<\/a> | <a href=\"http:\/\/demo.lyminhhoang.com\/download\/code\/recaptcha_demo.zip\">Download<\/a><\/p>\n\n\n\n<p>\u0110\u1ea7u ti\u1ec1n b\u1ea1n \u0111\u0103ng k\u00fd t\u1ea1i <a href=\"https:\/\/www.google.com\/recaptcha\/admin\">Google reCAPTCHA<\/a>  \u0111\u1ec3 nh\u1eadn Secret Key cho trang web c\u1ee7a b\u1ea1n. <\/p>\n\n\n\n<p>\u0110\u0103ng nh\u1eadp v\u00e0o t\u00e0i kho\u1ea3n Google c\u1ee7a b\u1ea1n v\u00e0 t\u1ea1o \u1ee9ng d\u1ee5ng b\u1eb1ng c\u00e1ch \u0111i\u1ec1n v\u00e0o bi\u1ec3u m\u1eabu.<\/p>\n\n\n\n<p>Ch\u1ecdn reCAPTCHA v3 .<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"672\" height=\"1024\" src=\"http:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/google-recaptcha-v3-01-672x1024.jpg\" alt=\"\" class=\"wp-image-6897\" srcset=\"https:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/google-recaptcha-v3-01-672x1024.jpg 672w, https:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/google-recaptcha-v3-01-197x300.jpg 197w, https:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/google-recaptcha-v3-01-768x1170.jpg 768w, https:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/google-recaptcha-v3-01.jpg 802w\" sizes=\"auto, (max-width: 672px) 100vw, 672px\" \/><\/figure>\n<\/div>\n\n\n<p>Sau khi g\u1eedi, Google s\u1ebd cung c\u1ea5p cho b\u1ea1n hai th\u00f4ng tin sau.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"804\" height=\"319\" src=\"http:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/google-recaptcha-v3-02.jpg\" alt=\"\" class=\"wp-image-6898\" srcset=\"https:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/google-recaptcha-v3-02.jpg 804w, https:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/google-recaptcha-v3-02-300x119.jpg 300w, https:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/google-recaptcha-v3-02-768x305.jpg 768w\" sizes=\"auto, (max-width: 804px) 100vw, 804px\" \/><\/figure>\n<\/div>\n\n\n<p>Ch\u00e8n \u0111o\u1ea1n code sau \u0111\u1ec3 t\u00edch h\u1ee3p Google reCAPTCHA v\u00e0o website c\u1ee7a b\u1ea1n<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;script src=&quot;https:\/\/www.google.com\/recaptcha\/api.js?render=put_your_site_key_here&quot;&gt;&lt;\/script&gt;\n<\/pre><\/div>\n\n\n<p>Google reCAPTCHA v3 \u0111\u00e3 \u0111\u01b0\u1ee3c ch\u00e8n th\u00e0nh c\u00f4ng v\u00e0o website c\u1ee7a b\u1ea1n<\/p>\n\n\n\n<p>B\u1ea1n c\u1ea7n x\u1eed l\u00fd ph\u1ea3n h\u1ed3i captcha c\u1ee7a google trong m\u00e3 JavaScript c\u1ee7a m\u00ecnh.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;script src=&quot;https:\/\/www.google.com\/recaptcha\/api.js?render=put_your_site_key_here&quot;&gt;&lt;\/script&gt;\n&lt;script&gt;\n  grecaptcha.ready(function() {\n      grecaptcha.execute(&#039;put your site key here&#039;, {action: &#039;homepage&#039;}).then(function(token) {\n        \/\/ pass the token to the backend script for verification\n      });\n  });\n&lt;\/script&gt;\n<\/pre><\/div>\n\n\n<p>Sau \u0111\u00e2y l\u00e0 \u0111o\u1ea1n code HTML ho\u00e0n ch\u1ec9nh v\u1ec1 c\u00e1ch th\u1ee9c s\u1eed d\u1ee5ng Google reCAPTCHA v3<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;Coming soon - Ly Minh Hoang&lt;\/title&gt;\n\n&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;\n&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text\/html; charset=utf-8&quot; \/&gt;\n\n&lt;script type=&quot;application\/x-javascript&quot;&gt;\n\taddEventListener(&quot;load&quot;, function() { \n\t\tsetTimeout(hideURLbar, 0); \n\t}, false);\n\tfunction hideURLbar(){ \n\t\twindow.scrollTo(0,1);\n\t}\n&lt;\/script&gt;\n&lt;link href=&quot;https:\/\/lyminhhoang.com\/layout\/css\/style.css&quot; rel=&quot;stylesheet&quot; type=&quot;text\/css&quot; media=&quot;all&quot; \/&gt;\n&lt;link href=&#039;https:\/\/fonts.googleapis.com\/css?family=Philosopher:400,400italic,700,700italic&#039; rel=&#039;stylesheet&#039; type=&#039;text\/css&#039;&gt;\n&lt;link href=&#039;https:\/\/fonts.googleapis.com\/css?family=Open+Sans:400,300,600,700,800&#039; rel=&#039;stylesheet&#039; type=&#039;text\/css&#039;&gt;\n&lt;script src=&quot;https:\/\/www.google.com\/recaptcha\/api.js?render=put_your_site_key_here&quot;&gt;&lt;\/script&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n\t\n\t&lt;div class=&quot;main&quot;&gt;\n\t\t&lt;h1&gt;Coming Soon&lt;\/h1&gt;\n\t\t&lt;div class=&quot;main-row&quot;&gt;\n\t\t\t&lt;p&gt;&lt;\/p&gt;\n\t\t\t&lt;div class=&quot;w3ls-img&quot;&gt; \n\t\t\t\t&lt;img src=&quot;layout\/images\/logo.png&quot; width=&quot;64px&quot; alt=&quot;&quot;\/&gt;\n\t\t\t&lt;\/div&gt;\t\n\t\t\t&lt;div class=&quot;agileits-timer&quot;&gt; \n\t\t\t\t &lt;div class=&quot;clock&quot;&gt;\n\t\t\t\t\t&lt;div class=&quot;column days&quot;&gt;\n\t\t\t\t\t\t&lt;div class=&quot;timer&quot; id=&quot;days&quot;&gt;&lt;\/div&gt;\n\t\t\t\t\t\t&lt;div class=&quot;text&quot;&gt;DAYS&lt;\/div&gt;\n\t\t\t\t\t&lt;\/div&gt;\n\t\t\t\t\t&lt;div class=&quot;timer days&quot;&gt;:&lt;\/div&gt;\n\t\t\t\t\t&lt;div class=&quot;column&quot;&gt;\n\t\t\t\t\t\t&lt;div class=&quot;timer&quot; id=&quot;hours&quot;&gt;&lt;\/div&gt;\n\t\t\t\t\t\t&lt;div class=&quot;text&quot;&gt;HOURS&lt;\/div&gt;\n\t\t\t\t\t&lt;\/div&gt;\n\t\t\t\t\t&lt;div class=&quot;timer&quot;&gt;:&lt;\/div&gt;\n\t\t\t\t\t&lt;div class=&quot;column&quot;&gt;\n\t\t\t\t\t\t&lt;div class=&quot;timer&quot; id=&quot;minutes&quot;&gt;&lt;\/div&gt;\n\t\t\t\t\t\t&lt;div class=&quot;text&quot;&gt;MINUTES&lt;\/div&gt;\n\t\t\t\t\t&lt;\/div&gt;\n\t\t\t\t\t&lt;div class=&quot;timer&quot;&gt;:&lt;\/div&gt;\n\t\t\t\t\t&lt;div class=&quot;column&quot;&gt;\n\t\t\t\t\t\t&lt;div class=&quot;timer&quot; id=&quot;seconds&quot;&gt;&lt;\/div&gt;\n\t\t\t\t\t\t&lt;div class=&quot;text&quot;&gt;SECONDS&lt;\/div&gt;\n\t\t\t\t\t&lt;\/div&gt;\n\t\t\t\t&lt;\/div&gt;\t\n\t\t\t&lt;\/div&gt;\n\t\t\t&lt;div class=&quot;wthree-sub&quot;&gt;\n\t\t\t\t&lt;form id=&quot;contact_form&quot; action=&quot;#&quot; method=&quot;post&quot;&gt;\n\t\t\t\t\t&lt;input type=&quot;email&quot; id=&quot;email&quot; name=&quot;Search&quot; placeholder=&quot;Enter your Email...&quot; required=&quot;&quot;&gt;\n\t\t\t\t\t&lt;button type=&quot;submit&quot; class=&quot;btn btn-default&quot; aria-label=&quot;Left Align&quot;&gt;\n\t\t\t\t\t\t&lt;img src=&quot;layout\/images\/i2.png&quot; alt=&quot;&quot;\/&gt;\n\t\t\t\t\t&lt;\/button&gt;\n\t\t\t\t&lt;\/form&gt;  \n\t\t\t&lt;\/div&gt;\t\n\t\t&lt;\/div&gt;\n\t\t&lt;!-- copyright --&gt;\n\t\t&lt;div class=&quot;copyright&quot;&gt;\n\t\t\t&lt;p&gt; \u00a9 2017 Coming Soon.&lt;\/p&gt;\n\t\t&lt;\/div&gt;\n\t\t&lt;!-- \/\/copyright --&gt;\n\t&lt;\/div&gt;\t\n\t&lt;script  src=&quot;https:\/\/lyminhhoang.com\/layout\/js\/jquery-1.12.3.min.js&quot;&gt;&lt;\/script&gt;\n\t&lt;script type=&quot;text\/javascript&quot; src=&quot;https:\/\/lyminhhoang.com\/layout\/js\/moment.js&quot;&gt;&lt;\/script&gt;\n\t&lt;script type=&quot;text\/javascript&quot; src=&quot;https:\/\/lyminhhoang.com\/layout\/js\/moment-timezone-with-data.js&quot;&gt;&lt;\/script&gt;\n\t&lt;script type=&quot;text\/javascript&quot; src=&quot;https:\/\/lyminhhoang.com\/layout\/js\/timer.js&quot;&gt;&lt;\/script&gt;\n\t\n\t&lt;script src=&quot;https:\/\/www.google.com\/recaptcha\/api.js?render=put_your_site_key_here&quot;&gt;&lt;\/script&gt;\n\t&lt;script&gt;\n\t\t$(&#039;#contact_form&#039;).submit(function() {\n\t\t\tevent.preventDefault();\n\t\t\tvar email = $(&#039;#email&#039;).val();\n\t\t\tgrecaptcha.ready(function() {\n\t\t\t\tgrecaptcha.execute(&#039;put_your_site_key_here&#039;, {action:&#039;contact_form&#039;}).then(function(token) {\n\t\t\t\t\t\n\t\t\t\t\t$(&#039;#contact_form&#039;).prepend(&#039;&lt;input type=&quot;hidden&quot; name=&quot;g-recaptcha-response&quot; value=&quot;&#039; + token + &#039;&quot;&gt;&#039;);\n\t\t\t\t\t\n\t\t\t\t\t$.post(&quot;contact.php&quot;,{email: email, token: token}, function(result) {\n                            \n\t\t\t\t\t\t\tconsole.log(result);\n\n                            if(result.success) {\n                                    alert(&#039;Thanks for posting comment.&#039;)\n                            } else {\n                                    alert(&#039;You are spammer ! Get the @$%K out.&#039;)\n                            }\n                    });\n\t\t\t\t\n\t\t\t  });\n\t\t\t});\n\t\t});\n\t&lt;\/script&gt;\n\t\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre><\/div>\n\n\n<p>Trang web c\u1ee7a b\u1ea1n s\u1ebd hi\u1ec3n th\u1ecb nh\u01b0 sau:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"564\" src=\"http:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/recaptcha_demo.jpg\" alt=\"\" class=\"wp-image-6907\" srcset=\"https:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/recaptcha_demo.jpg 1000w, https:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/recaptcha_demo-300x169.jpg 300w, https:\/\/tapchicntt.com\/wp-content\/uploads\/2019\/11\/recaptcha_demo-768x433.jpg 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p>Khi website c\u1ee7a b\u1ea1n hi\u1ec3n th\u1ecb nh\u01b0 tr\u00ean, b\u1ea1n \u0111\u00e3 t\u00edch h\u1ee3p th\u00e0nh c\u00f4ng  Google reCAPTCHA v3 <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\t$email;$captcha;\n\t$email = filter_input(INPUT_POST, &#039;email&#039;, FILTER_VALIDATE_EMAIL);\n\t$captcha = filter_input(INPUT_POST, &#039;token&#039;, FILTER_SANITIZE_STRING);\n  \n\tif(!$captcha){\n\t\techo &#039;&lt;h2&gt;Please check the the captcha form.&lt;\/h2&gt;&#039;;\n\t\texit;\n\t}\n\t$secretKey = &quot;-----put your secret here------&quot;;\n\t$ip = $_SERVER&#x5B;&#039;REMOTE_ADDR&#039;];\n\t\/\/ post request to server\n\t$url = &#039;https:\/\/www.google.com\/recaptcha\/api\/siteverify&#039;;\n\t$data = array(&#039;secret&#039; =&gt; $secretKey, &#039;response&#039; =&gt; $captcha);\n\t$options = array(\n\t\t&#039;http&#039; =&gt; array(\n\t\t\t&#039;header&#039;  =&gt; &quot;Content-type: application\/x-www-form-urlencoded\\r\\n&quot;,\n\t\t\t&#039;method&#039;  =&gt; &#039;POST&#039;,\n\t\t\t&#039;content&#039; =&gt; http_build_query($data)\n\t\t)\n\t);\n\t$context  = stream_context_create($options);\n\t$response = file_get_contents($url, false, $context);\n\t$responseKeys = json_decode($response,true);\n\theader(&#039;Content-type: application\/json&#039;);\n\tif($responseKeys&#x5B;&quot;success&quot;]) {\n\t\techo json_encode(array(&#039;success&#039; =&gt; &#039;true&#039;));\n\t} else {\n\t\techo json_encode(array(&#039;success&#039; =&gt; &#039;false&#039;));\n  }\n?&gt;\n<\/pre><\/div>\n\n\n<p>Ch\u00fac c\u00e1c b\u1ea1n th\u00e0nh c\u00f4ng! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google \u0111\u00e3 ra m\u1eaft reCAPTCHA v3 \u0111\u1ec3 ng\u0103n ch\u1eb7n c\u00e1c bot spam m\u00e0 kh\u00f4ng c\u00f3 b\u1ea5t k\u1ef3 s\u1ef1 t\u01b0\u01a1ng t\u00e1c [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":6907,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[142,212],"tags":[],"class_list":["post-6896","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thu-thuat-jquery","category-php-thu-thuat"],"views":780,"_links":{"self":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/posts\/6896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/comments?post=6896"}],"version-history":[{"count":10,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/posts\/6896\/revisions"}],"predecessor-version":[{"id":8137,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/posts\/6896\/revisions\/8137"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/media\/6907"}],"wp:attachment":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/media?parent=6896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/categories?post=6896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/tags?post=6896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}