Code: Select all
Procedure DrawReCaptcha(x,y,sitekey$)
If Len(sitekey$)>0
!try{
!var rcptcha=document.createElement('div');
!rcptcha.setAttribute('class','g-recaptcha');
!rcptcha.setAttribute('data-sitekey',v_sitekey$);
!rcptcha.setAttribute('style','position:fixed;z-index:9999999999999;top:'+v_y+';left:'+v_x+';');
!document.body.appendChild(rcptcha);
!var gscript=document.createElement('script');
!gscript.setAttribute('type','text/javascript');
!gscript.setAttribute('src','https://www.google.com/recaptcha/api.js');
!gscript.setAttribute('async','');
!gscript.setAttribute('defer','');
!document.getElementsByTagName('head')[0].appendChild(gscript);
!}catch(err){
!}
EndIf
EndProcedure
Procedure DeleteReCaptcha()
!try{
!document.body.removeChild(document.getElementByClass('g-recaptcha')[0]);
!}catch(err){
!}
EndProcedure
Procedure.s GetReCaptcha()
Protected answ$=""
!try{
!v_answ=grecaptcha.getResponse();
!}catch(err){
!}
ProcedureReturn answ$
EndProcedure
;demo
ExamineDesktops()
DrawReCaptcha((DesktopWidth(0)/2)-200,(DesktopHeight(0)/2)-200,"YOURSITEKEYHERE")
Repeat
;do stuff
Until Len(GetReCaptcha())>0
;send it to your server for verification with google api
- I haven't tested it just going by up to date docs and my experience writing it. You check GetReCaptcha() string on your back-end using cURL or whatever with the private-key and google returns some JSON you check.
- To use it in SB gadgets you calculate it's desktop x,y(not window-relative) and set this relative to it's x and y.
- You can use it in mobile apps by removing domain check in Google control panel(when SB team actually fixes http on Android and IOS)