当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::getCookieJar方法代码示例

本文整理汇总了PHP中Goutte\Client::getCookieJar方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getCookieJar方法的具体用法?PHP Client::getCookieJar怎么用?PHP Client::getCookieJar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Goutte\Client的用法示例。


在下文中一共展示了Client::getCookieJar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testUsesCookies

 public function testUsesCookies()
 {
     $guzzle = $this->getGuzzle();
     $client = new Client();
     $client->setClient($guzzle);
     $client->getCookieJar()->set(new Cookie('test', '123'));
     $crawler = $client->request('GET', 'http://www.example.com/');
     $request = $this->historyPlugin->getLastRequest();
     $this->assertEquals('123', $request->getCookie('test'));
 }
开发者ID:469306621,项目名称:Languages,代码行数:10,代码来源:ClientTest.php

示例2: testUsesCookiesWithCustomPort

 public function testUsesCookiesWithCustomPort()
 {
     $guzzle = $this->getGuzzle();
     $client = new Client();
     $client->setClient($guzzle);
     $client->getCookieJar()->set(new Cookie('test', '123'));
     $client->request('GET', 'http://www.example.com:8000/');
     $request = end($this->history)['request'];
     $this->assertEquals('test=123', $request->getHeaderLine('Cookie'));
 }
开发者ID:fabpot,项目名称:goutte,代码行数:10,代码来源:ClientTest.php

示例3: testFileCookieJar

 public function testFileCookieJar($testSaveSessionCookie = false)
 {
     $guzzle = $this->getGuzzle();
     $client = new Client();
     $client->setClient($guzzle);
     $filename = tempnam('/tmp', 'file-cookies');
     $jar = new FileCookieJar($filename, $testSaveSessionCookie);
     $client->setGuzzleCookieJar($jar);
     $client->getCookieJar()->set(new Cookie('test', '123'));
     $client->getCookieJar()->set(new Cookie('foo', 'bar', time() + 1000));
     $client->request('GET', 'http://www.example.com/');
     // Call to destruct method manually to test saving cookies
     $jar->__destruct();
     // Make sure it wrote to the file
     $contents = file_get_contents($filename);
     $this->assertNotEmpty($contents);
     // Load the cookieJar from the file
     $cookieJarReloaded = new FileCookieJar($filename);
     if ($testSaveSessionCookie) {
         $this->assertEquals(2, count($cookieJarReloaded));
     } else {
         $this->assertEquals(1, count($cookieJarReloaded));
     }
     unlink($filename);
 }
开发者ID:hoducha,项目名称:Goutte,代码行数:25,代码来源:ClientTest.php

示例4: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $this->client = new Client();
     // @FIXME without this Cookie the website serves a JavaScript only version - see known issues
     $this->client->getCookieJar()->set(new Cookie('TS017d4e39', '01e0f702cf037f97362f62278696546776e7b67bec0aece008837daa4d94f77fe53d7d4c8a6fa39200300641d6aee20da460dd376505f7550bd18461d59d5c2489e7bc515b97917c372e044bb84fb8441a011139863d71d7b41a83ffdab5f7f5dc3492855c362d61bdddc129cdd1d60c4ac9a1b702547433a79abd2e4c7c9a2f9f21e7c748fe9f995fea959736b5aea76fe14d45d2181a39b1f45823787c1cd69e0457f53c'));
 }
开发者ID:peterhough,项目名称:sainsburys,代码行数:9,代码来源:Scraper.php


注:本文中的Goutte\Client::getCookieJar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。