2
I am trying to increment a reCAPTCHA on a website, I have watched several step by step, but mine persists in giving the same error. code example:
index.php
<html xmlns="http://www.w3.org/1999/html">
<head>
<title>index</title>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<form method="post" action="verify.php">
<input type="text" name="inp"/></br>
<div class="g-recaptcha" data-sitekey="********************"></div>
<input type="submit"></br>
</form>
</body>
</html>
Verify.php
<?php
header("Content-type: text/php charset=utf-8");
if(isset($_POST['g-recaptcha-response'])&& $_POST['g-recaptcha-response']){
var_dump($_POST);
//informações sobre o reCAPTCHA
$secret = "**************************************************";
var_dump($secret);
$ip = $_SERVER['REMOTE_ADDR'];
var_dump($_SERVER);
$captcha = $_POST['g-recaptcha-response'];
var_dump($captcha);
//Enviar para o google
$rps = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=$captcha&remoteip$ip");
//resposta google
var_dump($rps);
// $arr = json_decode($rsp,true)
}else{
echo "reCAPTCHA não prenchido";
}
The error always occurs in the
$rps = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=$captcha&remoteip$ip");
The var_dump($rps);
should return "success": true
but always returns
Warning: file_get_contents() [Function.file-get-Contents]: URL file-access is disabled in the server Configuration in /home/Storage/2/8a/81/necon1/public_html/Verify.php online 13
See in PHP.ini, if you have access, the parameter
allow_url_fopen
or use CURL as mentioned in the answers.– Inkeliz