新的Google reCAPTCHA使用CodeIgniter 2.2.2每次我尝试运行我的测试,它返回一个错误的结果后,加载了很长一段时间与以下警告消息:
遇到PHP错误
严重性:警告
消息:文件获取内容(https://www.google.com/recaptcha/api/siteverify?secret=PUBLICKEY&response=03AHJ_VuvOwCxIKqGoZXeEOWvDxMjYrBsH9HyWpbxg1YmBTThs8gINjC5yEQOG0fVikDPY3GXemQVrB6DT965o0LARL2rRDP-U6m9Y9DSFdDvz55vwsewe4--m0NfssykJZ3et6zItKH7mNsDIi1LLtPrn7vaQmCGlK3LW2hS4Q8TMDhjTW-tecmCRbonCcTcvMN4gHnWuGzSzUFUlOPxAlSHEvkBHspZb5SnGLNakZ5rrF591LL9SS8NrZErFVO3EySpW_CCG26uDhpMJW5y5B_3nZnBYZqpmf0eIIMy5w3rk2FjJrPw2G8Kj98Cv1B1xJcXBgML7uCnZRmc7WDZhzFoI2JAeuEBNwQkQJvSGXsGLGkewz1ClPiQwzYZRlwEpgo2Zpkri6lrIlNMIc0dtmhM7U172LGELgjbNKFAW29Aq8wTOCwC2tztWlTn_8mq9SrS_mhhs7iaG&remoteip=127.0.0.1):无法打开流:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机没有响应。
文件名:首页
下面是我的html代码
<!DOCTYPE html>
<html lang="en">
<head>
<title>TEST</title>
</head>
<body>
<form action="validation" method="post">
<label for="name">Name:</label>
<input name="name" required><br />
<label for="email">Email:</label>
<input name="email" type="email" required><br />
<div class="g-recaptcha" data-sitekey="My_Public_Key"></div>
<input type="submit" value="Submit" />
</form>
<!--js-->
<script src='https://www.google.com/recaptcha/api.js'></script>
</body>
</html>
下面是我的PHP文件:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class cap extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->database();
$this->load->model('users_model', 'user');
$this->lang->load("message",$this->session->userdata('language'));
}
public function index() {
$this->load->view("cap");
}
public function validation()
{
$email;$comment;$captcha;
if(isset($_POST['email'])){
$email=$_POST['email'];
}if(isset($_POST['comment'])){
$email=$_POST['comment'];
}if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '<h2>Please check the the captcha form.</h2>';
exit;
}
remoteip=".$_SERVER['REMOTE_ADDR']);
$response=json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=MyPrivateKey&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']), true);
if($response['success'] == false)
{
echo '<h2>Wrong</h2>';
}else
{
echo '<h2>Correct</h2>';
}
}
}
?>
(Of当然我通过谷歌api网页生成了我的公钥和私钥)
伙计们,有什么想法吗?我需要在我的php里打开curl之类的吗?
2条答案
按热度按时间pb3s4cty1#
有可能
allow_url_fopen = Off
在您的php.ini
中,阻止file_get_contents
打开URL。你可以直接使用cURL来完成这个任务,比如:
4c8rllxm2#
在我的情况这是这问题与配置缓存..尝试到运行php工匠配置:清除在laravel