当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);
Run Code Online (Sandbox Code Playgroud)
特别来看看:
var l=a.ml;h.B?(h=h.B.responseText,0==h.indexOf(")]}'\n")&&(h=h.substring(5)),h=Hg(h)):h=void 0;`
Run Code Online (Sandbox Code Playgroud)
解析器显式检查值的开头)]}并剥离它。
我建议您在“ json”字符串上应用相同的子字符串