Recaptcha: Error on file_get_contents()

Created on 31 Mar 2015  路  5Comments  路  Source: google/recaptcha

I get errors, when I upload the code on web server, with the php variable allow_url_fopen that is set 0 for prevent ddos attacks, I've tried using cURL instead of file_get_contents but my codes doesn't works, so I'm asking for help with that and I think that this problem occurred with other people.
Sorry for my bad english.

Most helpful comment

The alternative ReCaptcha\RequestMethod\SocketPost method should work for you here. You can use this by replacing this line:

$recaptcha = new \ReCaptcha\ReCaptcha($secret);

with this line:

$recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\SocketPost());

All 5 comments

The alternative ReCaptcha\RequestMethod\SocketPost method should work for you here. You can use this by replacing this line:

$recaptcha = new \ReCaptcha\ReCaptcha($secret);

with this line:

$recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\SocketPost());

Can you put these detail into documentation, please? Not sooo "hidden" here in the queue...

  // Try to workaround locked down web servers.
  if (!ini_get('allow_url_fopen')) {
    // allow_url_fopen = Off
    $recaptcha = new \ReCaptcha\ReCaptcha($recaptcha_secret_key, new \ReCaptcha\RequestMethod\SocketPost());
  }
  else {
    // allow_url_fopen = On
    $recaptcha = new \ReCaptcha\ReCaptcha($recaptcha_secret_key);
  }

_Please_ mention this in the README!

_Please_ mention this in the README!

yes ... please
I have looked an hour for a solution and could't find anything there.
Maybe a Troubleshoot section?

It's 2019, and I'm with you guys.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luckyvs1 picture luckyvs1  路  9Comments

duesee picture duesee  路  3Comments

galford-tillster picture galford-tillster  路  5Comments

DFNCTSC picture DFNCTSC  路  14Comments

Antaris picture Antaris  路  11Comments