解决方法:无法连接到www.google.com:443。错误#0:stream_socket_client():无法连接到www.google.com:443(无主机路由)

时间:2019-02-12 02:10:22

标签: php recaptcha zend-framework3

我正在尝试在Zend Framework 3中使用recaptcha。提交表单时,出现错误:

  

无法连接到www.google.com:443。错误#0:stream_socket_client():无法连接到www.google.com:443(无路由到主机)

我的代码与Windows下的lockalhost上的测试键一起使用。但是不要在我的Linux主机上工作。

MyForm.php

<?php
use Zend\Captcha\ReCaptcha;
use Zend\Form\Element;

class MyForm extends Form {
  private const SITE_KEY = '';
  private const SECRET_KEY = '';
  public function __construct($name = null) {
    // Add some elements
    parent::__construct('new_password');
    $captcha = new Element\Captcha('captcha');
    $recaptcha = new ReCaptcha();
    $recaptcha->setSiteKey(self::SITE_KEY);
    $recaptcha->setSecretKey(self::SECRET_KEY);
    $captcha->setCaptcha($recaptcha);
    $captcha->setLabel('Please verify you are human');
    $this->add($captcha);
    // Add submit
  }
}
?>

my_template.phtml

<?php 
  $captcha = $form->get('captcha'); ?>
  <?php echo $this->form()->openTag($form); ?>
  <div>
    <?= $this->formLabel($captcha) ?>
    <?= $this->formElement($captcha) ?>
    <?= $this->formElementErrors()->render($captcha) ?>
  </div>
  <?php
    echo $this->formSubmit($submit);
    echo $this->form()->closeTag();
   ?>

请告诉我如何解决此问题。

0 个答案:

没有答案
相关问题