protected function setupCallbackUrl() { //Create and setup callback URL $this->callback_url = new Url(); $this->callback_url->setScheme('http'); $this->callback_url->setHost('ws.audioscrobbler.com'); $this->callback_url->setPath('/2.0/'); //2.0 - API version $this->callback_url->appendQuery("api_key={$this->key}"); if ($this->data_format == self::DATA_JSON) { $this->callback_url->appendQuery('format=json'); } //JSON result }
/** * @return bool */ public function validateRecaptcha() { $httpData = $this->getForm()->getHttpData(); if (!isset($httpData['g-recaptcha-response'])) { $this->addError($this->getFilledMessage()); return TRUE; } $this->validateKeys(); $url = new Url(); $url->setHost('www.google.com')->setScheme('https')->setPath('recaptcha/api/siteverify')->setQueryParameter('secret', $this->secretKey)->setQueryParameter('response', $httpData['g-recaptcha-response']); $data = json_decode(file_get_contents((string) $url)); if (!isset($data->success) || $data->success !== TRUE) { $this->addError($this->getValidMessage()); } return TRUE; }
public function validateRecaptcha() { $httpData = $this->getForm()->getHttpData(); if (!isset($httpData['g-recaptcha-response'])) { $this->addError('Please fill antispam.'); return TRUE; } $url = new Url(); $url->setHost('www.google.com')->setScheme('https')->setPath('recaptcha/api/siteverify')->setQueryParameter('secret', $this->secretKey)->setQueryParameter('response', $httpData['g-recaptcha-response']); $data = json_decode(file_get_contents((string) $url)); if (isset($data->success) && $data->success === TRUE) { return TRUE; } else { $this->addError('Antispam detection wasn\'t success.'); return TRUE; } }