Grey
Grey

Reputation: 891

google recaptcha Warning: Illegal string offset 'success'

I'm trying to implement the google recaptcha for the first time and am running into this error: Warning: Illegal string offset 'success'

this is the code that needs to check if the recaptcha works out:

$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=MYSECRETCODEHERE&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);

if($response["success"] == false){   
     echo('spam');
}else{
    echo('not spam');
}

Upvotes: 1

Views: 502

Answers (1)

Grey
Grey

Reputation: 891

thanks to @maximkou for giving the answer to my question, I had to change response["success"] == false to response == false

Upvotes: 2

Related Questions