本文整理匯總了PHP中Goutte\Client::setServerParameter方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::setServerParameter方法的具體用法?PHP Client::setServerParameter怎麽用?PHP Client::setServerParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Goutte\Client
的用法示例。
在下文中一共展示了Client::setServerParameter方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getWebClient
/**
* @return GoutteClient
*/
protected function getWebClient()
{
if (!$this->client) {
$this->client = new GoutteClient();
$this->client->setServerParameter('HTTP_USER_AGENT', 'Crawler');
}
return $this->client;
}
示例2: createClient
/**
* @return Client
*/
public function createClient()
{
$client = new Client();
$client->setServerParameter('HTTP_HOST', $this->host);
return $client;
}
示例3: testPostMultipartFormWithoutFiles
public function testPostMultipartFormWithoutFiles()
{
$guzzle = $this->getGuzzle();
$client = new Client();
$client->setClient($guzzle);
$params = array('foo' => 'bar');
$client->setServerParameter('Content-Type', 'multipart/form-data');
$client->request('POST', 'http://www.example.com/', $params);
/*
* @var Request
*/
$request = end($this->history)['request'];
$stream = $request->getBody();
$boundary = $stream->getBoundary();
$this->assertEquals("--{$boundary}\r\nContent-Disposition: form-data; name=\"foo\"\r\nContent-Length: 3\r\n" . "\r\nbar\r\n" . "--{$boundary}--\r\n", $stream->getContents());
}
示例4: getBrowser
/**
* Used internally to create/get the HTTP client
*
* @return Goutte\Client
*/
private function getBrowser()
{
if (!$this->browser instanceof Client) {
$browser = new Client();
$browser->setServerParameter('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)');
$this->browser = $browser;
}
return $this->browser;
}