json - recaptcha 从调用 https ://www. google.com/recaptcha/api2/userverify 获取无效 json

标签 json recaptcha

当 recaptcha 调用 https://www.google.com/recaptcha/api2/userverify?k=

它回来了

)]}' [“uvresp”,,,,2]

如果有一个有效的 k,它会返回更多的值。然而 )]}' 显然是无效的 json。 当我尝试使用 grecaptcha.getResponse() 检索响应时,我得到一个空字符串。

使用curl 时的结果相同。

如有任何帮助,我们将不胜感激。

最佳答案

实际上返回的值不是有效的 json,但可以被 Google 的 API 很好地解析。

这是一种保护吗?我不知道,但是如果你看看 JavaScript,你会发现:

var jm=function(a,b,c,d,e,g,h,l,r){this.xl=a;this.$c=c||"GET";this.Ka=d;this.Gg=e||null;this.Td=m(h)?h:1;this.ye=0;this.xh=this.Nh=!1;this.uh=b;this.Mh=g;this.md=l||"";this.Zb=!!r;this.Wf=null};f=jm.prototype;f.getUrl=function(){return this.xl};f.ug=function(){return this.$c};f.Ca=function(){return this.Ka};f.fi=function(){return this.Zb};f.bi=function(){return this.md};var nm=function(){G.call(this);this.nj=new hm(0,mm,1,10,5E3);H(this,this.nj);this.ad=0};x(nm,G);var mm=new Nh;nm.prototype.send=function(a){return new Lc(function(b,c){var d=String(this.ad++);this.nj.send(d,a.Uf.toString(),a.ug(),a.Ca(),mm,void 0,u(function(a,d){var h=d.target;if(Xk(h)){var l=a.ml;h.B?(h=h.B.responseText,0==h.indexOf(")]}'\n")&&(h=h.substring(5)),h=Hg(h)):h=void 0;b(new l(h))}else c(new om(a))},this,a))},this)};var om=function(a){y.call(this);this.request=a};x(om,y);

特别看看:

var l=a.ml;h.B?(h=h.B.responseText,0==h.indexOf(")]}'\n")&&(h=h.substring(5)),h=Hg(h)):h=void 0;`

解析器显式检查该值是否以 )]} 开头,并将其删除。

我建议您在“json”字符串上应用相同的子字符串

关于json - recaptcha 从调用 https ://www. google.com/recaptcha/api2/userverify 获取无效 json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35348234/

相关文章:

security - Google Re-Captcha 2 可以防止 CSRF 攻击吗?

php - 关于我的 Google Recaptcha 代码

node.js - 使用 Node.js 和 Express 进行 reCAPTCHA

javascript - angular.fromJson 和 $scope.$eval 应用于 JSON 字符串时的区别

javascript - 在 Express 中使用 Parse.Cloud.httpRequest 时出现问题,表示没有这样的成功方法 :

mysql - org.apache.spark.sql.AnalysisException : cannot recognize input near 'num' ':' '=' in expression specification;

asp.net - 如何将 reCAPTCHA ASP.NET 插件放入 Razor (CSHTML) 文件中?

javascript - 如何将 HTML 代码转换为 JSON 对象?

json - 获取 json 文件的概要

python - 改进 reCaptcha 2.0 解决自动化脚本(Selenium)