projectName($project); // Defina as propriedades do evento que será monitorado. $event = (new Event()) ->setSiteKey($recaptchaKey) ->setToken($token); // Crie a solicitação de avaliação. $assessment = (new Assessment()) ->setEvent($event); $request = (new CreateAssessmentRequest()) ->setParent($projectName) ->setAssessment($assessment); try { $response = $client->createAssessment($request); // Verifique se o token é válido. if ($response->getTokenProperties()->getValid() == false) { printf('The CreateAssessment() call failed because the token was invalid for the following reason: '); printf(InvalidReason::name($response->getTokenProperties()->getInvalidReason())); return; } // Verifique se a ação esperada foi executada. if ($response->getTokenProperties()->getAction() == $action) { // Consulte a pontuação de risco e os motivos. // Para mais informações sobre como interpretar a avaliação, acesse: // https://cloud.google.com/recaptcha/docs/interpret-assessment printf('The score for the protection action is:'); printf($response->getRiskAnalysis()->getScore()); } else { printf('The action attribute in your reCAPTCHA tag does not match the action you are expecting to score'); } } catch (exception $e) { printf('CreateAssessment() call failed with the following error: '); printf($e); } } // O que fazer: substitua o token e as variáveis de ação reCAPTCHA antes de executar a amostra. create_assessment( '6Ldg2mQsAAAAAMcoiSY7aKRkooaGsI9HrM3g8QDw', 'YOUR_USER_RESPONSE_TOKEN', 'rare-chiller-459213-j5', 'YOUR_RECAPTCHA_ACTION' ); ?>
Ir para o conteúdo