谷歌在ASP(经典)上重新收回一页

时间:2017-03-07 04:12:18

标签: php asp.net recaptcha

我现在在ASP工作。我喜欢用PHP编码,但我公司在他们的网站上使用ASP。在我的公司网站上有一个与我们的CRM相关联的表单,关于我们需要将多个垃圾邮件发送到表单中的许多垃圾邮件。

以下是我开发的许多网站上使用的recaptcha的PHP代码,在ASP上可以使用与此代码相同的方法吗?我只需要一页。

<?php
 if(isset($_POST['submit'])):
 if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha- response'])):
    //your site secret key
    $secret = '6Le5ohYUAAAAAAWeXQ4TnEMsOrW7wSw4WcNUVyS7';
    //get verify response data
    $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);
    $responseData = json_decode($verifyResponse);

    if($responseData->success):         
        $succMsg = 'Your contact request have submitted successfully.';
    else:
        $errMsg = 'Robot verification failed, please try again.';
    endif;
    else:
        $errMsg = 'Please click on the reCAPTCHA box.';
    endif;
else:
$errMsg = '';
$succMsg = '';
endif;
?>

<html>
<head>
  <title>Google reCAPTCHA</title>
   <script src="https://www.google.com/recaptcha/api.js" async defer>  </script>
</head>
<body>
<div class="registration">
    <h2>Contact Form</h2>
    <?php if(!empty($errMsg)): ?><div class="errMsg"><?php echo $errMsg; ?></div><?php endif; ?>
    <?php if(!empty($succMsg)): ?><div class="succMsg"><?php echo $succMsg; ?></div><?php endif; ?>
    <div class="form-info">
        <form action="" method="POST">
            <input type="text" class="text" value="<?php echo !empty($name)?$name:''; ?>" placeholder="Your full name" name="name" >
            <input type="text" class="text" value="<?php echo !empty($email)?$email:''; ?>" placeholder="Email adress" name="email" >
            <input type="text" placeholder="Message..." name="message"><?php echo !empty($message)?$message:''; ?></textarea>
            <div class="g-recaptcha" data-sitekey="6Le5ohYUAAAAAPDz2w2tDQ-3AgYwgEQmkOhnwYhO"></div>
            <input type="submit" name="submit" value="SUBMIT">
        </form>
    </div>          
    <div class="clear"> </div>
</div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

是的,您可以将Google recaotcha与Clasic ASP一起使用。你可以在这里看到他们的文件 https://developers.google.com/recaptcha/old/docs/asp