本文整理汇总了PHP中Nette\Http\Url::setHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::setHost方法的具体用法?PHP Url::setHost怎么用?PHP Url::setHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\Url
的用法示例。
在下文中一共展示了Url::setHost方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupCallbackUrl
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
}
示例2: validateRecaptcha
/**
* @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;
}
示例3: validateRecaptcha
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;
}
}