Ne reCAPTCHA gives me a 403 error

A client recently told me that his reCAPTCHA site is no longer working. After investigating, I found out that Google changed it. I have updated my site using the new documentation from 19 Nov 2014, but it always gives me a 403 error. I tried passing only the secret key and returned a JSON result with false and error. I did the same just by posting a response from the g-recaptcha-response field and it also returned an error JSON result. As soon as I put them in a string using http_build_query, I get banned from Google.

I am using the new http://www.google.com/recaptcha/api/siteverify URL. I am posting it with PHP cURL using the following code:

    $post_data = array('response'=>$response, 'secret'=>$privatekey);
    $curlPost = http_build_query($post_data, '', '&');

    $ch = curl_init();

    //Set the URL of the page or file to download.
    $url = 'http://www.google.com/recaptcha/api/siteverify';

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);

    $data_json = curl_exec($ch);

      

Any help would be greatly appreciated.

+3


source to share


1 answer


You must use https, so the correct url is:

$url = 'https://www.google.com/recaptcha/api/siteverify';

      



This should fix the 403 error.

+5


source







All Articles